Moved failed to find document into lib tests.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s

This commit is contained in:
2026-02-25 13:44:43 -05:00
parent 5251689158
commit 97f9d24330
8 changed files with 50 additions and 37 deletions

View File

@@ -130,10 +130,11 @@ impl Names {
where
NT: Into<NameType>,
{
match name.into() {
let name_type = name.into();
match name_type.clone() {
NameType::Name(data) => match self.names.get(&data) {
Some(id) => Ok(id.clone()),
None => Err(MTTError::new(ErrorID::NameNotFound)),
None => Err(MTTError::new(ErrorID::NameNotFound(name_type))),
},
NameType::ID(data) => {
if self.ids.contains_key(&data) {
@@ -142,7 +143,7 @@ impl Names {
if data == Uuid::nil() {
Ok(data)
} else {
Err(MTTError::new(ErrorID::NameNotFound))
Err(MTTError::new(ErrorID::NameNotFound(name_type)))
}
}
}
@@ -231,11 +232,12 @@ mod names {
#[test]
fn errors_on_bad_name() {
let name = Name::english(Uuid::new_v4().to_string().as_str());
let expected: NameType = name.clone().into();
let names = Names::new();
match names.get_id(name.clone()) {
Ok(data) => unreachable!("got {:?}, should have been missing error", data),
Err(err) => match err.get_error_ids().back().unwrap() {
ErrorID::NameNotFound => {}
ErrorID::NameNotFound(data) => assert_eq!(data, &expected),
_ => unreachable!("got {:?}, should have been missing error", err),
},
}
@@ -244,11 +246,12 @@ mod names {
#[test]
fn errors_on_bad_id() {
let id = Uuid::new_v4();
let expected: NameType = id.clone().into();
let names = Names::new();
match names.get_id(id.clone()) {
Ok(data) => unreachable!("got {:?}, should have been missing error", data),
Err(err) => match err.get_error_ids().back().unwrap() {
ErrorID::NameNotFound => {}
ErrorID::NameNotFound(data) => assert_eq!(data, &expected),
_ => unreachable!("got {:?}, should have been missing error", err),
},
}