use std::time::Duration;
use pretty_assertions::assert_eq;
use rho_protocol::display::{NotificationItem, NotificationUrgency};
use super::*;
#[test]
fn failed_process_card_shows_outcome_command_and_verbatim_output() {
let row = ProcessNotification {
process_id: "891ba4bc".into(),
command: "cargo test".into(),
state: State::Exited,
exit_code: Some(101),
output: "```rust\npanic!()\n```\n".into(),
terminal_detail: None,
elapsed: Duration::from_secs(65),
}
.row();
let process = || NotificationSubject::Process {
id: "891ba4bc".into(),
};
let info = row.info.expect("a process card is typed");
assert_eq!(
(info.urgency, info.subject, info.items),
(
NotificationUrgency::NeedsYou,
process(),
vec![NotificationItem::new(
NotificationOutcome::Failed,
NotificationUrgency::NeedsYou,
NotificationTone::Error,
process(),
"Failed (exit 101) · cargo test"
)],
)
);
assert_eq!(
row.card,
NotificationCard {
title: "Failed (exit 101) · cargo test".into(),
sender: "process".into(),
recipient: "parent".into(),
delivery: NotificationDelivery::Received,
tone: NotificationTone::Error,
preview: NotificationPreview::Truncated,
visibility: NotificationVisibility::Conversation,
reference: Some("891ba4bc".into()),
subtitle: Some("ran 1m 05s".into()),
body: String::new(),
output: Some("```rust\npanic!()\n```".into()),
details: vec![
"process: 891ba4bc".into(),
"command: cargo test".into(),
"exit code: 101".into(),
],
}
);
}