Readded missing fields test.
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:
parent
f69d5d2248
commit
1bb799cdce
@ -20,6 +20,7 @@ mod support_test {
|
|||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
enum MTTError {
|
enum MTTError {
|
||||||
|
AdditionMissingField(Name),
|
||||||
DocumentAlreadyExists(String),
|
DocumentAlreadyExists(String),
|
||||||
DocumentFieldAlreadyExists(String, Field),
|
DocumentFieldAlreadyExists(String, Field),
|
||||||
DocumentFieldMissing(String),
|
DocumentFieldMissing(String),
|
||||||
@ -28,6 +29,7 @@ enum MTTError {
|
|||||||
DocumentNotFound(String),
|
DocumentNotFound(String),
|
||||||
FieldDuplicate(String, Field),
|
FieldDuplicate(String, Field),
|
||||||
FieldMissingData,
|
FieldMissingData,
|
||||||
|
InvalidNone,
|
||||||
RecordMismatch,
|
RecordMismatch,
|
||||||
NameDuplicate(Name),
|
NameDuplicate(Name),
|
||||||
NameInvalidID(Uuid),
|
NameInvalidID(Uuid),
|
||||||
@ -2241,7 +2243,7 @@ impl FieldSetting {
|
|||||||
}
|
}
|
||||||
None => match &self.default_value {
|
None => match &self.default_value {
|
||||||
Some(calc) => Ok(calc.calculate()),
|
Some(calc) => Ok(calc.calculate()),
|
||||||
None => Err(MTTError::DocumentFieldMissing("".to_string())),
|
None => Err(MTTError::InvalidNone),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2283,8 +2285,8 @@ mod fieldsettings {
|
|||||||
match fset.validate(None) {
|
match fset.validate(None) {
|
||||||
Ok(data) => unreachable!("got {:?}: should have gotten an error", data),
|
Ok(data) => unreachable!("got {:?}: should have gotten an error", data),
|
||||||
Err(err) => match err {
|
Err(err) => match err {
|
||||||
MTTError::DocumentFieldMissing(data) => assert_eq!(data, ""),
|
MTTError::InvalidNone => {},
|
||||||
_ => unreachable!("got {:?}: should have gotten a value", err),
|
_ => unreachable!("got {:?}: should have gotten a invalid none", err),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4727,16 +4729,15 @@ mod document_files {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#[test]
|
#[test]
|
||||||
fn errors_on_wrong_field_type() {
|
fn errors_on_wrong_field_type() {
|
||||||
let (docdef, doc_name) = create_docdef([FieldType::Uuid].to_vec());
|
let mut test_doc = TestDocument::new([FieldType::Uuid].to_vec());
|
||||||
let (queue, rx) = test_doc(doc_name.as_str(), docdef, standard_routes());
|
test_doc.start();
|
||||||
|
let queue = test_doc.get_queue();
|
||||||
let mut addition = Addition::new();
|
let mut addition = Addition::new();
|
||||||
addition.add_field("field0".to_string(), "astring");
|
addition.add_field(Name::english("field0".to_string()), "string");
|
||||||
let msg = Message::new(doc_name, addition);
|
queue.send(Message::new(test_doc.get_docdef().get_document_name(), addition));
|
||||||
queue.send(msg).unwrap();
|
let result = test_doc.get_receiver().recv_timeout(TIMEOUT).unwrap();
|
||||||
let result = rx.recv_timeout(TIMEOUT).unwrap();
|
|
||||||
match result.get_action() {
|
match result.get_action() {
|
||||||
MsgAction::Error(err) => match err {
|
MsgAction::Error(err) => match err {
|
||||||
MTTError::DocumentFieldWrongDataType(expected, got) => {
|
MTTError::DocumentFieldWrongDataType(expected, got) => {
|
||||||
@ -4754,22 +4755,23 @@ mod document_files {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn errors_on_missing_fields() {
|
fn errors_on_missing_fields() {
|
||||||
let (docdef, doc_name) = create_docdef([FieldType::Uuid, FieldType::Uuid].to_vec());
|
let mut test_doc = TestDocument::new([FieldType::Integer, FieldType::Integer].to_vec());
|
||||||
let (queue, rx) = test_doc(doc_name.as_str(), docdef, standard_routes());
|
test_doc.start();
|
||||||
|
let queue = test_doc.get_queue();
|
||||||
let mut addition = Addition::new();
|
let mut addition = Addition::new();
|
||||||
addition.add_field("field0".to_string(), Uuid::nil());
|
addition.add_field(Name::english("field0".to_string()), 1);
|
||||||
let msg = Message::new(doc_name, addition);
|
queue.send(Message::new(test_doc.get_docdef().get_document_name(), addition));
|
||||||
queue.send(msg).unwrap();
|
let result = test_doc.get_receiver().recv_timeout(TIMEOUT).unwrap();
|
||||||
let result = rx.recv_timeout(TIMEOUT).unwrap();
|
|
||||||
match result.get_action() {
|
match result.get_action() {
|
||||||
MsgAction::Error(err) => match err {
|
MsgAction::Error(err) => match err {
|
||||||
MTTError::DocumentFieldMissing(field) => assert_eq!(field, "field1"),
|
MTTError::InvalidNone => {},
|
||||||
_ => unreachable!("got {:?}: should have been document field missing", err),
|
_ => unreachable!("got {:?}: should have been document field missing", err),
|
||||||
},
|
},
|
||||||
_ => unreachable!("got {:?}: should have been an error", result.get_action()),
|
_ => unreachable!("got {:?}: should have been an error", result.get_action()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#[test]
|
#[test]
|
||||||
fn does_query_return_related_entries() {
|
fn does_query_return_related_entries() {
|
||||||
let mut doc = TestDocument::new([FieldType::Uuid].to_vec());
|
let mut doc = TestDocument::new([FieldType::Uuid].to_vec());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user