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
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Role {
Ok,
Warn,
Fail,
Pending,
Running,
Skipped,
Info,
/// "Attention without alarm" — a terminal-positive notable change that does
/// not warrant `Warn` severity. Mirrors `gh merged`, cargo's `Running`,
/// homebrew's yellow-bg new-formula highlight. Suppressed at `Verbosity::Quiet`.
Accent,
/// "Structural pivot / label / identifier" — names a thing (a source, a
/// scope, a module-kind) rather than carrying severity. Mirrors brew's
/// `==>` bold-blue, kubecolor's resource-kind magenta. Suppressed at
/// `Verbosity::Quiet`.
Secondary,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn role_serializes_lowercase() {
let json = serde_json::to_string(&Role::Ok).unwrap();
assert_eq!(json, "\"ok\"");
let json = serde_json::to_string(&Role::Fail).unwrap();
assert_eq!(json, "\"fail\"");
}
#[test]
fn role_round_trips() {
for r in [
Role::Ok,
Role::Warn,
Role::Fail,
Role::Pending,
Role::Running,
Role::Skipped,
Role::Info,
Role::Accent,
Role::Secondary,
] {
let s = serde_json::to_string(&r).unwrap();
let back: Role = serde_json::from_str(&s).unwrap();
assert_eq!(r, back);
}
}
#[test]
fn accent_and_secondary_serialize_lowercase() {
assert_eq!(serde_json::to_string(&Role::Accent).unwrap(), "\"accent\"");
assert_eq!(
serde_json::to_string(&Role::Secondary).unwrap(),
"\"secondary\""
);
}
}