Skip to content

D-037: test: cover ChangeStatus Deleted and Renamed variants#7

Open
Sephyi wants to merge 1 commit intodevelopmentfrom
audit/d-037-changestatus-fixtures
Open

D-037: test: cover ChangeStatus Deleted and Renamed variants#7
Sephyi wants to merge 1 commit intodevelopmentfrom
audit/d-037-changestatus-fixtures

Conversation

@Sephyi
Copy link
Copy Markdown
Owner

@Sephyi Sephyi commented Apr 22, 2026

Summary

test: cover ChangeStatus Deleted and Renamed variants.

Audit context

Closes audit entry D-037 from #3.

Verification

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-targets

Note: one pre-existing test porcelain_exits_within_timeout_with_no_staged_changes is a known macOS cold-start flake that reproduces on unmodified development — unrelated to this change.

Per audit D-037, the test suite never constructed `ChangeStatus::Deleted`
or meaningfully exercised `ChangeStatus::Renamed` through the splitter or
context builder. This closes that gap:

tests/helpers.rs
  - Extract `make_renamed_file_with_diff` so rename fixtures can carry a
    non-empty diff body plus explicit add/delete counts. The original
    `make_renamed_file` becomes a thin wrapper for existing callers.

tests/context.rs
  - Extend `format_files_shows_renamed_marker` to assert the old path,
    the `->` arrow, and the new path all appear in `file_breakdown` —
    proving `old_path` is respected, not silently dropped.
  - Add `format_files_mixed_statuses_show_all_markers`: one FileChange
    per variant in a single StagedChanges, asserting every `[+]`/`[M]`/
    `[-]`/`[R]` prefix and every `change_summary` count fires.

tests/splitter.rs
  - `deleted_file_is_represented_in_splitter_output`: a deleted file
    colocated with a sibling modification must land in exactly one group
    (or the SingleCommit branch) — never dropped.
  - `deleted_file_is_placed_into_a_splitter_group`: with a symbol-bearing
    addition in an unrelated module, the deletion still lands in exactly
    one split group.
  - `renamed_file_grouped_by_new_path_module`: the splitter must key
    module detection off the new path, not `old_path`.
  - `renamed_file_is_placed_into_a_splitter_group_with_old_path_preserved`:
    splitter output references the rename by its new path, and both
    `old_path` and `rename_similarity` round-trip unchanged on the input.

Closes audit entry D-037 from #3.
Copilot AI review requested due to automatic review settings April 22, 2026 19:49
@Sephyi Sephyi added the audit Codebase audit cleanup (issue #3) label Apr 22, 2026
@Sephyi Sephyi self-assigned this Apr 22, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds regression tests to ensure ChangeStatus::Deleted and ChangeStatus::Renamed are exercised in test fixtures, addressing audit item D-037 by covering splitter grouping and context formatting paths for these variants.

Changes:

  • Add CommitSplitter tests that include Deleted and Renamed FileChange fixtures and assert expected grouping/output inclusion.
  • Extend context formatting tests to verify deleted/renamed markers, including old_path -> new_path rendering and summary counts.
  • Enhance test helpers with a make_renamed_file_with_diff constructor to build rename fixtures with explicit diff bodies and add/delete stats.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tests/splitter.rs Adds new splitter tests for Deleted/Renamed fixtures and grouping expectations.
tests/helpers.rs Introduces make_renamed_file_with_diff and routes make_renamed_file through it.
tests/context.rs Adds assertions and a new test to cover formatting/summary output for all ChangeStatus variants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/splitter.rs
"src/services/llm/anthropic.rs",
ChangeStatus::Modified,
"@@ -0,0 +1,20 @@\n+pub fn brand_new_api() {}\n",
20,
Comment thread tests/splitter.rs
Comment on lines +722 to +723
"@@ -0,0 +1,20 @@\n+pub fn brand_new_api() {}\n",
20,
Comment thread tests/splitter.rs
ChangeStatus::Deleted,
"@@ -1,10 +0,0 @@\n-pub fn retired() {}\n-pub fn also_retired() {}\n",
0,
10,
Comment thread tests/splitter.rs
Comment on lines +595 to +601
SplitSuggestion::SingleCommit => {
// Single-commit means all files fall into the one implicit group
// — the deleted file is still present in the input, so no further
// assertion is needed beyond verifying the input shape.
assert!(changes.files.iter().any(|f| f.path == deleted_path));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit Codebase audit cleanup (issue #3)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants