From 28146fc259bb60b907ab703d6e093df89a8c000b Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 23 Feb 2026 22:02:55 +0000 Subject: [PATCH] story-kit: merge 101_story_test_coverage_http_chat_rs_to_80 --- server/src/http/chat.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/server/src/http/chat.rs b/server/src/http/chat.rs index de3ff1e..137d589 100644 --- a/server/src/http/chat.rs +++ b/server/src/http/chat.rs @@ -23,3 +23,36 @@ impl ChatApi { Ok(Json(true)) } } + +#[cfg(test)] +mod tests { + use super::*; + use tempfile::TempDir; + + fn test_api(dir: &TempDir) -> ChatApi { + ChatApi { + ctx: Arc::new(AppContext::new_test(dir.path().to_path_buf())), + } + } + + #[tokio::test] + async fn cancel_chat_returns_true() { + let dir = TempDir::new().unwrap(); + let api = test_api(&dir); + let result = api.cancel_chat().await; + assert!(result.is_ok()); + assert!(result.unwrap().0); + } + + #[tokio::test] + async fn cancel_chat_sends_cancel_signal() { + let dir = TempDir::new().unwrap(); + let api = test_api(&dir); + let mut cancel_rx = api.ctx.state.cancel_rx.clone(); + cancel_rx.borrow_and_update(); + + api.cancel_chat().await.unwrap(); + + assert!(*cancel_rx.borrow()); + } +}