Started moving update tests into lib.

This commit is contained in:
2026-03-01 13:33:03 -05:00
parent 224096cbdb
commit 00d8283fb9
6 changed files with 88 additions and 12 deletions

View File

@@ -97,3 +97,52 @@ fn does_it_error_on_missing_fields() {
let result = mtt.records(add).unwrap_err();
assert_eq!(result.to_string(), expected.to_string());
}
#[test]
fn can_default_values_be_used() {
let mut mtt = MoreThanText::new();
let ftype = FieldType::StaticString;
let test_doc = TestDocument::new(vec![ftype.clone()]);
let mut docdef = test_doc.get_docdef();
docdef.set_default(&test_doc.get_field_name(0), ftype.clone());
mtt.create_document(docdef);
let add = Addition::new(test_doc.get_doc_name().clone());
let results = mtt.records(add).unwrap();
let rec = results.iter().last().unwrap();
assert_eq!(rec.get(test_doc.get_field_name(0)).unwrap(), "".into());
}
#[test]
fn can_default_values_be_set() {
let mut mtt = MoreThanText::new();
let ftype = FieldType::StaticString;
let fdefault = Uuid::new_v4().to_string();
let test_doc = TestDocument::new(vec![ftype.clone()]);
let mut docdef = test_doc.get_docdef();
docdef.set_default(&test_doc.get_field_name(0), fdefault.clone());
mtt.create_document(docdef);
let add = Addition::new(test_doc.get_doc_name().clone());
let results = mtt.records(add).unwrap();
let rec = results.iter().last().unwrap();
assert_eq!(
rec.get(test_doc.get_field_name(0)).unwrap(),
fdefault.into()
);
}
#[test]
fn can_default_values_be_overwritten() {
let mut mtt = MoreThanText::new();
let ftype = FieldType::StaticString;
let fdefault = Uuid::new_v4().to_string();
let used = "something";
let test_doc = TestDocument::new(vec![ftype.clone()]);
let mut docdef = test_doc.get_docdef();
docdef.set_default(&test_doc.get_field_name(0), fdefault.clone());
mtt.create_document(docdef);
let mut add = Addition::new(test_doc.get_doc_name().clone());
add.add_field(test_doc.get_field_name(0), used);
let results = mtt.records(add).unwrap();
let rec = results.iter().last().unwrap();
assert_eq!(rec.get(test_doc.get_field_name(0)).unwrap(), used.into());
}