Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Convert bare repository tests to snapshot-based assertions
Maximilian Roos812c98d311b6
diff --git a/tests/integration_tests/bare_repository.rs b/tests/integration_tests/bare_repository.rsindex 48bf783eb..bfcb4f36d 100644--- a/tests/integration_tests/bare_repository.rs+++ b/tests/integration_tests/bare_repository.rs@@ -189,18 +189,15 @@ fn test_bare_repo_list_shows_no_bare_entry() {let main_worktree = test.create_worktree("main", "main");test.commit_in_worktree(&main_worktree, "Initial commit");- // Run wt list and verify bare repo is NOT shown- let mut cmd = wt_command();- test.configure_wt_cmd(&mut cmd);- cmd.arg("list").current_dir(&main_worktree);-- let output = cmd.output().unwrap();- let stdout = String::from_utf8_lossy(&output.stdout);+ // Run wt list and verify bare repo is NOT shown (only main worktree appears)+ let settings = setup_temp_snapshot_settings(test.temp_path());+ settings.bind(|| {+ let mut cmd = wt_command();+ test.configure_wt_cmd(&mut cmd);+ cmd.arg("list").current_dir(&main_worktree);- // Should only show the main worktree, not the bare repo (table output is on stdout)- assert!(stdout.contains("main"));- assert!(!stdout.contains(".git"));- assert!(!stdout.contains("bare"));+ assert_cmd_snapshot!(cmd);+ });}#[test]@@ -337,16 +334,14 @@ fn test_bare_repo_identifies_primary_correctly() {let _feature2 = test.create_worktree("feature2", "feature2");// Run wt list to see which is marked as primary- let mut cmd = wt_command();- test.configure_wt_cmd(&mut cmd);- cmd.arg("list").current_dir(&main_worktree);-- let output = cmd.output().unwrap();- let stdout = String::from_utf8_lossy(&output.stdout);+ let settings = setup_temp_snapshot_settings(test.temp_path());+ settings.bind(|| {+ let mut cmd = wt_command();+ test.configure_wt_cmd(&mut cmd);+ cmd.arg("list").current_dir(&main_worktree);- // First non-bare worktree (main) should be primary (table output is on stdout)- // The exact formatting may vary, but main should be listed- assert!(stdout.contains("main"));+ assert_cmd_snapshot!(cmd);+ });}#[test]@@ -435,25 +430,15 @@ fn test_bare_repo_commands_from_bare_directory() {test.commit_in_worktree(&main_worktree, "Initial commit");// Run wt list from the bare repo directory itself (not from a worktree)- let mut cmd = wt_command();- test.configure_wt_cmd(&mut cmd);- cmd.arg("list").current_dir(test.bare_repo_path());-- let output = cmd.output().unwrap();-- if !output.status.success() {- panic!(- "wt list from bare repo failed:\nstdout: {}\nstderr: {}",- String::from_utf8_lossy(&output.stdout),- String::from_utf8_lossy(&output.stderr)- );- }-- let stdout = String::from_utf8_lossy(&output.stdout);+ // Should list the worktree even when run from bare repo, not showing bare repo itself+ let settings = setup_temp_snapshot_settings(test.temp_path());+ settings.bind(|| {+ let mut cmd = wt_command();+ test.configure_wt_cmd(&mut cmd);+ cmd.arg("list").current_dir(test.bare_repo_path());- // Should list the worktree even when run from bare repo (table output is on stdout)- assert!(stdout.contains("main"), "Should show main worktree");- assert!(!stdout.contains("bare"), "Should not show bare repo itself");+ assert_cmd_snapshot!(cmd);+ });}/// Test that merge workflow works correctly with bare repositories.diff --git a/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_commands_from_bare_directory.snap b/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_commands_from_bare_directory.snapnew file mode 100644index 000000000..2e6127ad8--- /dev/null+++ b/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_commands_from_bare_directory.snap@@ -0,0 +1,31 @@+---+source: tests/integration_tests/bare_repository.rs+info:+ program: wt+ args:+ - list+ env:+ CLICOLOR_FORCE: ""+ COLUMNS: "150"+ 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"+ LANG: C+ LC_ALL: C+ NO_COLOR: ""+ RUST_LOG: warn+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----+ [1mBranch[0m [1mStatus[0m [1mHEAD±[0m [1mmain↕[0m [1mPath[0m [1mRemote⇅[0m [1mCommit[0m [1mAge[0m [1mMessage[0m+^ main [2m^[22m . [2mb834638e[0m [2m1d[0m [2mInitial commit[0m++[2m○[22m [2mShowing 1 worktree[0m++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_identifies_primary_correctly.snap b/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_identifies_primary_correctly.snapnew file mode 100644index 000000000..304713257--- /dev/null+++ b/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_identifies_primary_correctly.snap@@ -0,0 +1,33 @@+---+source: tests/integration_tests/bare_repository.rs+info:+ program: wt+ args:+ - list+ env:+ CLICOLOR_FORCE: ""+ COLUMNS: "150"+ 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"+ LANG: C+ LC_ALL: C+ NO_COLOR: ""+ RUST_LOG: warn+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----+ [1mBranch[0m [1mStatus[0m [1mHEAD±[0m [1mmain↕[0m [1mPath[0m [1mRemote⇅[0m [1mCommit[0m [1mAge[0m [1mMessage[0m+@ main [2m^[22m . [2mb37a293c[0m [2m1d[0m [2mMain commit[0m++ [2mfeature1[0m [2m_[22m [2m../feature1[0m [2mb37a293c[0m [2m1d[0m [2mMain commit[0m++ [2mfeature2[0m [2m_[22m [2m../feature2[0m [2mb37a293c[0m [2m1d[0m [2mMain commit[0m++[2m○[22m [2mShowing 3 worktrees[0m++----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_shows_no_bare_entry.snap b/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_shows_no_bare_entry.snapnew file mode 100644index 000000000..265fb1c6f--- /dev/null+++ b/tests/snapshots/integration__integration_tests__bare_repository__bare_repo_list_shows_no_bare_entry.snap@@ -0,0 +1,31 @@+---+source: tests/integration_tests/bare_repository.rs+info:+ program: wt+ args:+ - list+ env:+ CLICOLOR_FORCE: ""+ COLUMNS: "150"+ 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"+ LANG: C+ LC_ALL: C+ NO_COLOR: ""+ RUST_LOG: warn+ SOURCE_DATE_EPOCH: "1735776000"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+---+success: true+exit_code: 0+----- stdout -----+ [1mBranch[0m [1mStatus[0m [1mHEAD±[0m [1mmain↕[0m [1mPath[0m [1mRemote⇅[0m [1mCommit[0m [1mAge[0m [1mMessage[0m+@ main [2m^[22m . [2mb834638e[0m [2m1d[0m [2mInitial commit[0m++[2m○[22m [2mShowing 1 worktree[0m++----- stderr -----