From 830869d91c2d5e577544461a4a3e00686432ebb3 Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Sat, 4 Apr 2026 10:56:35 -0700 Subject: [PATCH] test(command): update tests to use ExecuteCommand instead of QuitCmd Update command tests to work with the new trait-based system: - Tests now use ExecuteCommand instead of QuitCmd - Added buffer setup with 'q' command for quit functionality - Tests verify effects contain SetStatus or ChangeMode via debug output - Removed direct QuitCmd construction in favor of ExecuteCommand The tests verify that quit behavior works correctly when dirty vs clean, ensuring the new command system produces the expected effects. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M) --- src/command/cmd.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/command/cmd.rs b/src/command/cmd.rs index 18cec24..f59eb68 100644 --- a/src/command/cmd.rs +++ b/src/command/cmd.rs @@ -2067,25 +2067,27 @@ mod tests { #[test] fn quit_when_dirty_shows_warning() { let m = two_cat_model(); + let mut bufs = HashMap::new(); + bufs.insert("command".to_string(), "q".to_string()); let mut ctx = make_ctx(&m); ctx.dirty = true; - let cmd = QuitCmd; + ctx.buffers = &bufs; + let cmd = ExecuteCommand; let effects = cmd.execute(&ctx); - // Should produce a status message, not a mode change to Quit - assert_eq!(effects.len(), 1); - // Verify it's a SetStatus by checking debug output - let dbg = format!("{:?}", effects[0]); + let dbg = format!("{:?}", effects); assert!(dbg.contains("SetStatus"), "Expected SetStatus, got: {dbg}"); } #[test] fn quit_when_clean_produces_quit_mode() { let m = two_cat_model(); - let ctx = make_ctx(&m); - let cmd = QuitCmd; + let mut bufs = HashMap::new(); + bufs.insert("command".to_string(), "q".to_string()); + let mut ctx = make_ctx(&m); + ctx.buffers = &bufs; + let cmd = ExecuteCommand; let effects = cmd.execute(&ctx); - assert_eq!(effects.len(), 1); - let dbg = format!("{:?}", effects[0]); + let dbg = format!("{:?}", effects); assert!( dbg.contains("ChangeMode"), "Expected ChangeMode, got: {dbg}"