morethantext/tests/lib_document_test.rs

32 lines
973 B
Rust
Raw Normal View History

2026-02-06 12:06:51 -05:00
use morethantext::{
2026-02-06 13:07:34 -05:00
action::{DocDef, FieldType, Query},
ErrorID, MTTError, MoreThanText, Name,
2026-02-06 12:06:51 -05:00
};
use uuid::Uuid;
2026-02-03 11:37:58 -05:00
#[test]
fn errors_on_missing_page() {
let mtt = MoreThanText::new();
let doc_name = "missing";
2026-02-06 12:06:51 -05:00
match mtt.get_document(doc_name, "something") {
2026-02-03 11:37:58 -05:00
Ok(data) => assert!(false, "got '{}', should have been not found error", data),
Err(err) => {
let err_id = err.error_id();
match err_id {
ErrorID::DocumentNotFound => {}
_ => unreachable!("got {:?}, should have been not found", err),
}
}
2026-02-03 11:37:58 -05:00
}
}
2026-02-06 12:06:51 -05:00
#[test]
fn can_create_document() {
let mut mtt = MoreThanText::new();
let doc_name = Name::english(Uuid::new_v4().to_string().as_str());
let mut docdef = DocDef::new(doc_name.clone());
let field_name = Name::english(Uuid::new_v4().to_string().as_str());
docdef.add_field(field_name.clone(), FieldType::Uuid);
mtt.request(docdef);
}