Skip to content

test(strategy): combine and remove redundant tests#1301

Merged
computermode merged 1 commit into
mainfrom
dedupe-strategy-tests
May 29, 2026
Merged

test(strategy): combine and remove redundant tests#1301
computermode merged 1 commit into
mainfrom
dedupe-strategy-tests

Conversation

@computermode
Copy link
Copy Markdown
Contributor

@computermode computermode commented May 29, 2026

https://entire.io/gh/entireio/cli/trails/457

What

Found and consolidated redundant tests in cmd/entire/cli/strategy — tests that exercised the exact same functionality were either combined into table-driven tests or removed when fully subsumed by another test.

Candidate redundancies were identified by analyzing all 37 test files in the package, then each was verified by reading the actual code before any change. Only HIGH-confidence cases (genuinely identical behavior) were acted on.

Net: 18 redundant test functions collapsed into 7 — 510 deletions, 262 insertions. No loss of coverage; every distinct case survives as a named subtest row.

Changes

File Before → After Action & why
common_test.go 8 TestReadAgentTypeFromTree_* → 1 Identical bodies differing only in which agent dir(s) were written and the expected AgentType. Merged into a table-driven test. Kept _MetadataJSON_OverridesDir separate (distinct metadata-override branch).
manual_commit_test.go 4 TestMarshalPromptAttributionsIncludingPending_* → 1 Same function, same assertion shape, varying only by input state (committed/pending/empty/pending-only). Merged into a table.
manual_commit_test.go TestCommittedFilesExcludingMetadata_AllMetadata removed All-metadata case is a strict subset of TestCommittedFilesExcludingMetadata; folded its assertion into the base test.
manual_commit_condensation_test.go 3 TestCalculateTokenUsage_Cursor* → 1 All asserted "Cursor always returns nil token usage", varying only by transcript shape and offset. Merged into _CursorAlwaysNil.
phase_postcommit_test.go _IdleSession_SkipsSentinelWait + _EndedSession_SkipsSentinelWait → 1 Bodies were byte-identical except the session phase. Merged into _NonActiveSession_SkipsSentinelWait (subtest per phase).
manual_commit_migration_test.go TestMigrateShadowBranch_CommitObjectFailure removed Identical inputs (no-trailer commit, session with LastCheckpointID) and identical assertions to _MigratePathPinsAttribution.
session_test.go TestSessionCheckpointCount, TestEmptySession removed Trivial struct round-trips that are strict subsets of TestSessionStruct.
session_state_test.go _WithEndedAt + _WithLastInteractionTime → 1 Structurally identical save/load round-trips differing only in which *time.Time field is set. Merged into _OptionalTimeFields.

Deliberately left alone

Several structurally-similar tests were verified to cover genuinely different behavior and were not touched:

  • Push/remote layered tests (SafelyAdvanceLocalRefFetchMetadataBranchFetchV2MainFromURL) — same invariant, different production functions with distinct historical bugs.
  • Diverged-vs-orphan replay pairs — different code paths (merge-base found vs. fallback).
  • condense_skip entry-point pair and StoreAgentTypeHint/ClaimSessionStartBanner — different functions/contracts.

Helper-level duplication (inline gitRun closures, repeated repo bootstrap) was flagged by analysis but is out of scope here — it's helper de-duplication, not redundant tests.

Verification

  • go test ./cmd/entire/cli/strategy/ok (38s)
  • mise run lint0 issues

🤖 Generated with Claude Code


Note

Low Risk
Test-only refactors in the strategy package; behavior is validated by existing and merged subtests, with no runtime code changes.

Overview
This PR refactors tests only in cmd/entire/cli/strategy: redundant cases are folded into table-driven tests or dropped when another test already covers the same behavior. Production code is unchanged.

Eight ReadAgentTypeFromTree_* tests become one table (single vs ambiguous agent dirs, no dirs). Four marshalPromptAttributionsIncludingPending variants merge into one table; the all-metadata committedFilesExcludingMetadata assertion moves into the main test. Three Cursor CalculateTokenUsage nil checks merge into TestCalculateTokenUsage_CursorAlwaysNil. Idle and ended PostCommit sentinel-wait regressions share TestPostCommit_NonActiveSession_SkipsSentinelWait. TestMigrateShadowBranch_CommitObjectFailure is removed as duplicate of the migrate-path pin test. Trivial Session struct tests and separate EndedAt / LastInteractionTime round-trips consolidate into TestLoadSessionState_OptionalTimeFields.

Net effect: fewer test functions, same named subtest coverage; PR description cites ~510 lines removed and ~262 added with go test ./cmd/entire/cli/strategy/ passing.

Reviewed by Cursor Bugbot for commit 9bda6bd. Configure here.

Consolidate tests in cmd/entire/cli/strategy that exercised identical
functionality into table-driven tests, and remove ones fully subsumed by
others. No loss of coverage — every distinct case survives as a named
subtest row.

Net: 18 redundant test functions collapsed into 7 (510 deletions, 262
insertions).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: a8d84d083b26
Copilot AI review requested due to automatic review settings May 29, 2026 23:08
@computermode computermode requested a review from a team as a code owner May 29, 2026 23:08
Copy link
Copy Markdown
Contributor

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 refactors redundant tests in cmd/entire/cli/strategy by consolidating equivalent cases into table-driven tests and removing tests fully covered by retained cases. It is test-only and does not change production behavior.

Changes:

  • Consolidates repeated agent detection, prompt attribution, token usage, session-state, and post-commit regression tests.
  • Folds redundant assertions into existing tests where behavior was already covered.
  • Removes duplicate migration/session struct tests with no runtime code changes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cmd/entire/cli/strategy/common_test.go Combines ReadAgentTypeFromTree fallback cases into one table-driven test.
cmd/entire/cli/strategy/manual_commit_test.go Merges prompt attribution tests and folds all-metadata filtering assertion into the main test.
cmd/entire/cli/strategy/manual_commit_condensation_test.go Consolidates Cursor token-usage nil cases into one table-driven test.
cmd/entire/cli/strategy/manual_commit_migration_test.go Removes a duplicate migration-path test.
cmd/entire/cli/strategy/phase_postcommit_test.go Merges idle/ended non-active sentinel-wait regression tests.
cmd/entire/cli/strategy/session_state_test.go Combines optional time field save/load tests into one table-driven test.
cmd/entire/cli/strategy/session_test.go Removes redundant struct-only session tests.

@computermode computermode merged commit fe5c8d3 into main May 29, 2026
11 checks passed
@computermode computermode deleted the dedupe-strategy-tests branch May 29, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants