Added missing index check.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s

This commit is contained in:
Jeff Baskin 2025-09-16 08:12:13 -04:00
parent 14020cd25f
commit 8efa797494

View File

@ -2238,6 +2238,7 @@ impl DocumentFile {
reply.add(docs[1].clone());
for (key, value) in docs[0].iter() {
self.remove_from_index(key, value, oid);
self.add_to_index(key, docs[1].get_field(key).unwrap().clone(), oid.clone());
}
}
reply.into()
@ -3036,7 +3037,7 @@ mod document_files {
}
#[test]
fn can_field_be_marked_unique() {
fn does_update_maintain_unique_fields() {
let (mut docdef, doc_name) = create_docdef([FieldType::Uuid].to_vec());
docdef.add_index("field0".to_string(), IndexType::Unique);
let (queue, rx) = test_doc(doc_name.as_str(), docdef, standard_routes());
@ -3089,7 +3090,7 @@ mod document_files {
}
#[test]
fn updating_unique_removes_old_entry() {
fn updating_unique_updates_index_entries() {
let (mut docdef, doc_name) = create_docdef([FieldType::Uuid].to_vec());
docdef.add_index("field0".to_string(), IndexType::Unique);
let (queue, rx) = test_doc(doc_name.as_str(), docdef, standard_routes());
@ -3146,6 +3147,22 @@ mod document_files {
}
_ => unreachable!("got {:?}: should have gotten a reply", action),
}
addition.add_field("field0".to_string(), new.clone());
let msg = Message::new(doc_name.clone(), addition.clone());
queue.send(msg).unwrap();
let result = rx.recv_timeout(TIMEOUT).unwrap();
let action = result.get_action();
match action {
MsgAction::Error(err) => match err {
MTTError::FieldDuplicate(key, field) => {
let expected: Field = new.into();
assert_eq!(key, "field0");
assert_eq!(field, &expected);
}
_ => unreachable!("got {:?}: should have gotten an missing field", err),
},
_ => unreachable!("got {:?}: should have gotten an error", action),
}
}
#[test]