-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_test.rs
More file actions
75 lines (66 loc) · 1.83 KB
/
error_test.rs
File metadata and controls
75 lines (66 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use keyring_cli::error::Error;
#[test]
fn test_crypto_error_display() {
let err = Error::Crypto {
context: "test failed".to_string(),
};
assert_eq!(err.to_string(), "Crypto error: test failed");
}
#[test]
fn test_database_error_display() {
let err = Error::Database {
context: "query failed".to_string(),
};
assert_eq!(err.to_string(), "Database error: query failed");
}
#[test]
fn test_from_anyhow() {
let anyhow_err = anyhow::anyhow!("internal error");
let err: Error = anyhow_err.into();
assert!(matches!(err, Error::Internal { .. }));
}
#[test]
fn test_invalid_input_error_display() {
let err = Error::InvalidInput {
context: "empty password".to_string(),
};
assert_eq!(err.to_string(), "Invalid input: empty password");
}
#[test]
fn test_not_found_error_display() {
let err = Error::NotFound {
resource: "password record".to_string(),
};
assert_eq!(err.to_string(), "Not found: password record");
}
#[test]
fn test_authentication_failed_error_display() {
let err = Error::AuthenticationFailed {
reason: "wrong master password".to_string(),
};
assert_eq!(
err.to_string(),
"Authentication failed: wrong master password"
);
}
#[test]
fn test_clipboard_error_display() {
let err = Error::Clipboard {
context: "pbcopy not found".to_string(),
};
assert_eq!(err.to_string(), "Clipboard error: pbcopy not found");
}
#[test]
fn test_sync_error_display() {
let err = Error::Sync {
context: "cloud connection failed".to_string(),
};
assert_eq!(err.to_string(), "Sync error: cloud connection failed");
}
#[test]
fn test_mcp_error_display() {
let err = Error::Mcp {
context: "MCP protocol error".to_string(),
};
assert_eq!(err.to_string(), "MCP error: MCP protocol error");
}