diff options
Diffstat (limited to 'crates/atuin-daemon/tests')
| -rw-r--r-- | crates/atuin-daemon/tests/lifecycle.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/crates/atuin-daemon/tests/lifecycle.rs b/crates/atuin-daemon/tests/lifecycle.rs index 3b6952de..4a91e5cb 100644 --- a/crates/atuin-daemon/tests/lifecycle.rs +++ b/crates/atuin-daemon/tests/lifecycle.rs @@ -146,6 +146,56 @@ mod unix { } #[tokio::test] + async fn test_tail_history_streams_started_and_ended_events() { + use atuin_client::history::History; + use atuin_daemon::history::HistoryEventKind; + + let (mut client, _handle, _tmp) = start_test_daemon().await; + let mut stream = client.tail_history().await.unwrap(); + + let history = History::daemon() + .timestamp(time::OffsetDateTime::now_utc()) + .command("git status".to_string()) + .cwd("/tmp/repo".to_string()) + .session("tail-session".to_string()) + .hostname("test-host:ellie".to_string()) + .author("claude".to_string()) + .intent("inspect repository state".to_string()) + .build() + .into(); + + let start_reply = client.start_history(history).await.unwrap(); + + let started = stream.message().await.unwrap().unwrap(); + assert_eq!( + HistoryEventKind::try_from(started.kind).unwrap(), + HistoryEventKind::Started + ); + let started_history = started.history.unwrap(); + assert_eq!(started_history.id, start_reply.id); + assert_eq!(started_history.command, "git status"); + assert_eq!(started_history.cwd, "/tmp/repo"); + assert_eq!(started_history.hostname, "test-host:ellie"); + assert_eq!(started_history.author, "claude"); + assert_eq!(started_history.intent, "inspect repository state"); + + client + .end_history(start_reply.id.clone(), 1_000_000, 0) + .await + .unwrap(); + + let ended = stream.message().await.unwrap().unwrap(); + assert_eq!( + HistoryEventKind::try_from(ended.kind).unwrap(), + HistoryEventKind::Ended + ); + let ended_history = ended.history.unwrap(); + assert_eq!(ended_history.id, start_reply.id); + assert_eq!(ended_history.exit, 0); + assert_eq!(ended_history.duration, 1_000_000); + } + + #[tokio::test] async fn test_end_unknown_history_fails() { let (mut client, _handle, _tmp) = start_test_daemon().await; |
