Made MTTError a proper Error structure.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s

This commit is contained in:
2026-02-12 22:49:19 -05:00
parent 7ff9ca340f
commit a9b87200ef
12 changed files with 156 additions and 164 deletions

View File

@@ -104,7 +104,7 @@ impl From<UserAction> for MsgAction {
#[cfg(test)]
mod msgactions {
use super::*;
use crate::name::Name;
use crate::{mtterror::ErrorID, name::Name};
use uuid::Uuid;
#[test]
@@ -120,23 +120,20 @@ mod msgactions {
#[test]
fn turn_error_into_action() {
let data = "data".to_string();
let value = MTTError::DocumentAlreadyExists(data.clone());
let result: MsgAction = value.into();
let doc_name = Name::english(Uuid::new_v4().to_string().as_str());
let expected_name: NameType = doc_name.clone().into();
let error = ErrorID::DocumentNameAlreadyExists;
let err = MTTError::new(doc_name.clone(), error.clone());
let result: MsgAction = err.into();
match result {
MsgAction::Error(result) => match result {
MTTError::DocumentAlreadyExists(output) => assert_eq!(output, data),
_ => unreachable!("Got {:?}: dhould have been create", result),
},
_ => unreachable!("Got {:?}: dhould have been create", result),
}
let value = MTTError::DocumentNotFound(data.clone());
let result: MsgAction = value.into();
match result {
MsgAction::Error(result) => match result {
MTTError::DocumentNotFound(output) => assert_eq!(output, data),
_ => unreachable!("Got {:?}: dhould have been create", result),
},
MsgAction::Error(err) => {
assert_eq!(err.doc_name(), &expected_name);
let err_id = err.error_id();
match err_id {
ErrorID::DocumentNameAlreadyExists => {}
_ => unreachable!("got {:?}, expected document name exists", err_id),
}
}
_ => unreachable!("Got {:?}: dhould have been create", result),
}
}