From 53c38e157fde1f53f8048ba014ed11b3bbad5722 Mon Sep 17 00:00:00 2001 From: Jerry Kingsbury Date: Fri, 2 May 2025 17:10:32 -0500 Subject: [PATCH] test(monitor): remove nonexistent workspace Created a test for moving a workspace that doesn't exist. The test attempts to remove a workspace that doesn't exist and checks to ensure the removed_workspace variable is None. --- komorebi/src/monitor.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/komorebi/src/monitor.rs b/komorebi/src/monitor.rs index 57e69fd4..0a5223f8 100644 --- a/komorebi/src/monitor.rs +++ b/komorebi/src/monitor.rs @@ -631,6 +631,25 @@ mod tests { assert_eq!(m.workspaces().len(), 0); } + #[test] + fn test_remove_nonexistent_workspace() { + let mut m = Monitor::new( + 0, + Rect::default(), + Rect::default(), + "TestMonitor".to_string(), + "TestDevice".to_string(), + "TestDeviceID".to_string(), + Some("TestMonitorID".to_string()), + ); + + // Try to remove a workspace that doesn't exist + let removed_workspace = m.remove_workspace_by_idx(1); + + // Should return None since there is no workspace at index 1 + assert!(removed_workspace.is_none()); + } + #[test] fn test_focus_workspace() { let mut m = Monitor::new(