Skip to content

test: move tests to the tests/ directory - #20

Merged
joaolfp merged 1 commit into
mainfrom
test/move-to-tests-dir
Nov 16, 2026
Merged

joaolfp merged 1 commit into
mainfrom
test/move-to-tests-dir

Conversation

@joaolfp

@joaolfp joaolfp commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Moves every inline #[cfg(test)] mod tests out of src/ into Rust's standard tests/ directory: tests/git.rs, tests/diff.rs, tests/ui.rs, tests/app.rs, tests/theme.rs, plus tests/common/mod.rs with the shared TempRepo helper.
  • Adds src/lib.rs exposing the modules (integration tests can only use a library's public API); src/main.rs now uses the gitrat lib.
  • Makes public the helpers the tests exercise: Repo::root(), diff::changed_ranges, theme::rgb_to_256, app::delete_last_word and the ui truncation helpers. The push test now adds the remote via plain git instead of the private Repo::run.
  • Updates CLAUDE.md to describe the new layout.

No behavior change; the same 21 tests run.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test (21 passed)

🤖 Generated with Claude Code


Note

Low Risk
Test and project-structure refactor only; no changes to TUI or git command behavior beyond widening a few APIs for tests.

Overview
Refactors the crate so integration tests live under tests/ (git, diff, ui, app, theme) with shared TempRepo in tests/common/mod.rs, instead of inline #[cfg(test)] blocks in src/.

Adds src/lib.rs and wires main.rs through the gitrat library. Test-only helpers are pub: Repo::root(), diff::changed_ranges, theme::rgb_to_256, app::delete_last_word, and the UI truncation/scroll helpers. The push integration test adds remotes via TempRepo::git rather than private Repo::run.

CLAUDE.md documents the lib/binary split and the external test layout. No runtime behavior change — the same 21 tests exercise the same logic.

Reviewed by Cursor Bugbot for commit 931b8f6. Bugbot is set up for automated code reviews on this repo. Configure here.

Move the inline #[cfg(test)] modules into integration tests under
tests/ (one file per module) with a shared TempRepo helper in
tests/common. Add src/lib.rs exposing the modules so the tests can
reach them, and make the helpers they exercise public (Repo::root,
changed_ranges, rgb_to_256, delete_last_word, truncation helpers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joaolfp
joaolfp merged commit 0f85925 into main Nov 16, 2026
5 checks passed
@joaolfp
joaolfp deleted the test/move-to-tests-dir branch November 16, 2026 00:30
@joaolfp joaolfp mentioned this pull request Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant