Files
IdeA/crates/application/tests/error_codes.rs
Blomios 307ae71857 feat: add main features
Agents for developpement added + frontend add + backend added. Git viewer created + agent and template creator + layout and project creator
2026-06-06 01:27:01 +02:00

58 lines
1.8 KiB
Rust

//! L1 tests pinning the stable [`AppError::code`] strings the IPC `ErrorDto`
//! relies on, and the per-port `From` mappings.
use application::AppError;
use domain::ports::{FsError, GitError, ProcessError, PtyError, RemoteError, StoreError};
#[test]
fn codes_are_stable() {
assert_eq!(AppError::NotFound("x".into()).code(), "NOT_FOUND");
assert_eq!(AppError::Invalid("x".into()).code(), "INVALID");
assert_eq!(AppError::FileSystem("x".into()).code(), "FILESYSTEM");
assert_eq!(AppError::Store("x".into()).code(), "STORE");
assert_eq!(AppError::Process("x".into()).code(), "PROCESS");
assert_eq!(AppError::Git("x".into()).code(), "GIT");
assert_eq!(AppError::Remote("x".into()).code(), "REMOTE");
assert_eq!(AppError::Internal("x".into()).code(), "INTERNAL");
}
#[test]
fn fs_not_found_maps_to_not_found_other_to_filesystem() {
assert_eq!(
AppError::from(FsError::NotFound("/tmp/x".into())).code(),
"NOT_FOUND"
);
assert_eq!(
AppError::from(FsError::PermissionDenied("/tmp/x".into())).code(),
"FILESYSTEM"
);
assert_eq!(AppError::from(FsError::Io("boom".into())).code(), "FILESYSTEM");
}
#[test]
fn store_not_found_maps_to_not_found_other_to_store() {
assert_eq!(AppError::from(StoreError::NotFound).code(), "NOT_FOUND");
assert_eq!(
AppError::from(StoreError::Serialization("bad".into())).code(),
"STORE"
);
}
#[test]
fn process_pty_runtime_map_to_process() {
assert_eq!(AppError::from(PtyError::NotFound).code(), "PROCESS");
assert_eq!(
AppError::from(ProcessError::Spawn("x".into())).code(),
"PROCESS"
);
}
#[test]
fn git_and_remote_map_through() {
assert_eq!(AppError::from(GitError::NotFound).code(), "GIT");
assert_eq!(
AppError::from(RemoteError::Auth("nope".into())).code(),
"REMOTE"
);
}