Added the ability to populate test documents.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use morethantext::{DocDef, FieldType, Name};
|
||||
use morethantext::{Addition, DocDef, Field, FieldType, MoreThanText, Name};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub fn random_name() -> Name {
|
||||
@@ -40,4 +40,20 @@ impl TestDocument {
|
||||
pub fn get_field_name(&self, position: usize) -> Name {
|
||||
self.field_names[position].clone()
|
||||
}
|
||||
|
||||
pub fn populate<F>(&self, mtt: &mut MoreThanText, data: Vec<F>) where F: Into<Field> + Clone {
|
||||
let wrapper = vec![data];
|
||||
self.populate_multiple(mtt, wrapper);
|
||||
}
|
||||
|
||||
pub fn populate_multiple<F>(&self, mtt: &mut MoreThanText, data: Vec<Vec<F>>) where F: Into<Field> + Clone {
|
||||
for rec in data.iter() {
|
||||
let mut add = Addition::new(self.doc_name.clone());
|
||||
for i in 0..self.field_names.len() {
|
||||
let field: Field = rec[i].clone().into();
|
||||
add.add_field(self.field_names[i].clone(), field);
|
||||
}
|
||||
mtt.records(add).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user