Conversation
Move the integration test `TestRepo` from `tests/common/mod.rs` into `src/testing/mod.rs`, replacing the lightweight unit test version. One canonical struct now serves both unit and integration tests. Key changes: - `_snapshot_guard: insta::...` → `_lifetime_guard: Option<Box<dyn Any>>` (type-erased, removes insta dependency from src/) - Added `pub repo: Repository` field for unit test consumers - `TestRepo::new()` = lightweight git init (unit tests) - `TestRepo::standard()` = fixture copy with remote + worktrees (integration) - `tests/common/` re-exports via `pub use worktrunk::testing::*` - Moved `mock_commands` module to `src/testing/` - Consolidated gitconfig creation via `write_test_gitconfig()` Co-Authored-By: Claude <noreply@anthropic.com>
CI failed — TestRepo::new() missing local git identity
worktrunk-bot
left a comment
There was a problem hiding this comment.
CI fails: all commands::picker::summary::tests panic with "Author identity unknown" on t.repo.run_command(&["commit", ...]).
Root cause: The old src/testing.rs::TestRepo::new() set identity in the repo's local git config via repo.run_command(&["config", "user.name", "Test"]). The new TestRepo::new() writes identity to an external gitconfig file (write_test_gitconfig) and uses it via GIT_CONFIG_GLOBAL in configure_git_env. But Repository::run_command() doesn't set GIT_CONFIG_GLOBAL, so tests that commit via t.repo.run_command() fail.
Fix options:
- Have
TestRepo::new()also set local git config identity (like the old version did), sorepo.run_command()works without env setup - Change the picker tests to use
t.run_git()/t.git_command()instead oft.repo.run_command()
Option 1 is simplest and most backward-compatible — the tests are calling a reasonable API (t.repo.run_command) and shouldn't need to know about env isolation.
TestRepo::new() writes identity to an external gitconfig file accessed via GIT_CONFIG_GLOBAL. But unit tests commit via repo.run_command() which doesn't set that env var, causing "Author identity unknown" on CI. Fix: also set user.name/user.email in the repo's local git config. Co-Authored-By: Claude <noreply@anthropic.com>
The doctest can't resolve the function from a #[doc(hidden)] module. The same logic is tested in the #[cfg(test)] mod below. Co-Authored-By: Claude <noreply@anthropic.com>
…cover tests (#1997) Deduplicate the ~20 lines of identical setup between `TestRepo::new()` and `TestRepo::empty()` into a private `init_repo()` method. Migrate two recover.rs tests that only need "a repo with a commit" from manual `git_init() + set_test_identity()` to `TestRepo::with_initial_commit()`. The remaining 8 recover tests keep their local pattern — they intentionally create sibling/nested repo layouts within a shared tempdir that TestRepo doesn't support. Follow-up to #1991. > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude <noreply@anthropic.com>
Two
TestRepostructs existed — a lightweight one insrc/testing.rs(74 lines, for unit tests) and a full-featured one intests/common/mod.rs(~1500 lines, for integration tests). This consolidates them into one struct insrc/testing/that serves both.The key blocker was the integration TestRepo's
_snapshot_guard: insta::internals::SettingsBindDropGuardfield —instais a dev-dependency and can't appear inpubcode insrc/. Replaced withOption<Box<dyn Any>>(type-erased). Snapshot guard setup moved to therepo()rstest fixture.What moved to
src/testing/:TestRepostruct with all ~80 methodsBareRepoTest,TestRepoBasetraitmock_commandsmoduleTEST_EPOCH, timing constants, etc.)What stayed in
tests/common/:repo(),repo_with_*, etc.)insta::Settingscode)portable_ptycode)pub use worktrunk::testing::*Constructor semantics:
TestRepo::new()— lightweightgit init+ identity (backward-compatible with unit tests)TestRepo::standard()— fixture copy with remote + worktrees + mock gh (what integrationnew()was)TestRepo::with_initial_commit()— lightweight + one commitTestRepo::empty()—git initwith no commits