Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
test: convert absolute-path detached worktree tests to non-snapshot (#1684)
Maximilian Roos23858bc6b7ea
diff --git a/tests/integration_tests/remove.rs b/tests/integration_tests/remove.rsindex 03dea4ea5..2c720bf3d 100644--- a/tests/integration_tests/remove.rs+++ b/tests/integration_tests/remove.rs@@ -1823,24 +1823,31 @@ fn test_remove_detached_by_name_fails(mut repo: TestRepo) {assert_cmd_snapshot!(make_snapshot_cmd(&repo, "remove", &["(detached)"], None));}-/// Verify that detached worktrees can be removed by path (#1661).+/// Verify that detached worktrees can be removed by absolute path (#1661)./// This ensures the CLI supports the same operation the picker uses.#[rstest]fn test_remove_detached_worktree_by_path(mut repo: TestRepo) {- repo.add_worktree("feature-detached");+ let worktree_path = repo.add_worktree("feature-detached");repo.detach_head_in_worktree("feature-detached");- let worktree_path = repo- .worktree_path("feature-detached")- .to_string_lossy()- .to_string();+ assert!(worktree_path.exists());- assert_cmd_snapshot!(make_snapshot_cmd(- &repo,- "remove",- &[&worktree_path, "--foreground", "--yes"],- None,- ));+ let worktree_str = worktree_path.to_string_lossy().to_string();+ let output = repo+ .wt_command()+ .args(["remove", &worktree_str, "--foreground", "--yes"])+ .output()+ .unwrap();++ assert!(+ output.status.success(),+ "wt remove should succeed: {}",+ String::from_utf8_lossy(&output.stderr)+ );+ assert!(+ !worktree_path.exists(),+ "Worktree directory should be removed"+ );}/// Verify that detached worktrees can be removed by relative path.diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rsindex 498dec618..43328c75a 100644--- a/tests/integration_tests/switch.rs+++ b/tests/integration_tests/switch.rs@@ -994,21 +994,23 @@ fn test_switch_error_path_occupied_detached(repo: TestRepo) {snapshot_switch_with_directive_file("switch_error_path_occupied_detached", &repo, &["feature"]);}-/// Switch to a detached worktree by path (#1661).+/// Switch to a detached worktree by absolute path (#1661).#[rstest]fn test_switch_detached_worktree_by_path(mut repo: TestRepo) {- repo.add_worktree("feature-detached");+ let worktree_path = repo.add_worktree("feature-detached");repo.detach_head_in_worktree("feature-detached");- let worktree_path = repo- .worktree_path("feature-detached")- .to_string_lossy()- .to_string();+ let worktree_str = worktree_path.to_string_lossy().to_string();+ let output = repo+ .wt_command()+ .args(["switch", &worktree_str])+ .output()+ .unwrap();- snapshot_switch_with_directive_file(- "switch_detached_worktree_by_path",- &repo,- &[&worktree_path],+ assert!(+ output.status.success(),+ "wt switch should succeed: {}",+ String::from_utf8_lossy(&output.stderr));}diff --git a/tests/snapshots/integration__integration_tests__remove__remove_detached_worktree_by_path.snap b/tests/snapshots/integration__integration_tests__remove__remove_detached_worktree_by_path.snapdeleted file mode 100644index 31d9dae47..000000000--- a/tests/snapshots/integration__integration_tests__remove__remove_detached_worktree_by_path.snap+++ /dev/null@@ -1,48 +0,0 @@-----source: tests/integration_tests/remove.rs-info:- program: wt- args:- - remove- - /tmp/.tmph0CPwB/repo.feature-detached- - "--foreground"- - "--yes"- env:- APPDATA: "[TEST_CONFIG_HOME]"- CLICOLOR_FORCE: "1"- COLUMNS: "500"- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- GIT_TERMINAL_PROMPT: "0"- HOME: "[TEST_HOME]"- LANG: C- LC_ALL: C- MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"- NO_COLOR: ""- PATH: "[PATH]"- PSModulePath: ""- RUST_LOG: warn- SHELL: ""- TERM: alacritty- USERPROFILE: "[TEST_HOME]"- WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"- WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"- WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"- WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"- WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"- WORKTRUNK_TEST_EPOCH: "1735776000"- WORKTRUNK_TEST_NUSHELL_ENV: "0"- WORKTRUNK_TEST_POWERSHELL_ENV: "0"- WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"- XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"-----success: true-exit_code: 0------ stdout ------------ stderr ------[36m◎[39m [36mRemoving worktree @ [1m_REPO_.feature-detached[22m... (detached HEAD, no branch to delete)[39m-[32m✓[39m [32mRemoved worktree @ [1m_REPO_.feature-detached[22m (detached HEAD, no branch to delete)[39mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_detached_worktree_by_path.snap b/tests/snapshots/integration__integration_tests__switch__switch_detached_worktree_by_path.snapdeleted file mode 100644index cf528dfb6..000000000--- a/tests/snapshots/integration__integration_tests__switch__switch_detached_worktree_by_path.snap+++ /dev/null@@ -1,47 +0,0 @@-----source: tests/integration_tests/switch.rs-info:- program: wt- args:- - switch- - /private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpj2sTWR/repo.feature-detached- env:- APPDATA: "[TEST_CONFIG_HOME]"- CLICOLOR_FORCE: "1"- COLUMNS: "500"- GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"- GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"- GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"- GIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""- GIT_TERMINAL_PROMPT: "0"- HOME: "[TEST_HOME]"- LANG: C- LC_ALL: C- MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"- NO_COLOR: ""- PATH: "[PATH]"- PSModulePath: ""- RUST_LOG: warn- SHELL: ""- TERM: alacritty- USERPROFILE: "[TEST_HOME]"- WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"- WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"- WORKTRUNK_DIRECTIVE_FILE: "[DIRECTIVE_FILE]"- WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"- WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"- WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"- WORKTRUNK_TEST_EPOCH: "1735776000"- WORKTRUNK_TEST_NUSHELL_ENV: "0"- WORKTRUNK_TEST_POWERSHELL_ENV: "0"- WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"- XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"-----success: true-exit_code: 0------ stdout ------------ stderr ------[33m▲[39m [33mBranch-worktree mismatch: [1mrepo.feature-detached[22m @ [1m_REPO_.feature-detached[22m, expected @ [1m_REPO_.repo.feature-detached[22m [31m⚑[39m[39m-[2m○[22m Switched to worktree for [1mrepo.feature-detached[22m @ [1m_REPO_.feature-detached[22m