Skip to content

Test refactoring: self-contained improvements to redo #478

@wesm

Description

@wesm

Tier 1: High Value, Self-Contained (no production changes needed)

These are the highest-priority targets. Each can be done independently.

# File Pattern Summary
1 internal/storage/verdict_test.go Table-driven consolidation Consolidate ~200 verdict parsing test cases from scattered variable slices into a single table-driven structure with shared runVerdictTests helper
2 internal/daemon/server_jobs_test.go Helper extraction, table-driven Extract listJobsResponse type and fetchJobs helper; convert 8 repetitive filter/limit subtests into table-driven format
3 internal/daemon/server_output_test.go Consolidation Consolidate 6 separate TestHandleJobOutput_* functions into subtests with shared setup and jobOutputResponse type
4 internal/daemon/server_actions_test.go Isolation fix Convert TestHandleCancelJob from 5 sequential subtests sharing mutable state into table-driven test with isolated setup per case
5 internal/agent/kiro_test.go Table-driven Convert 6 separate TestStripKiroOutput* functions into one table-driven test with wantContains/wantMissing/exactMatch fields
6 internal/agent/acp_auth_test.go Helper extraction Extract setupTestClient and assertPermissionOutcome helpers, reducing per-test boilerplate from ~25 lines to ~5
7 internal/storage/db_filter_test.go Helper extraction, table-driven Extract seedJobs/findJob helpers; convert TestListJobsWithRepoFilter subtests into independent table-driven tests
8 internal/daemon/ci_repo_resolver_test.go Table-driven Consolidate 8 separate TestRepoResolver_* functions into one table-driven TestRepoResolver_Matching
9 internal/github/comment_test.go Mock helpers Replace inline multi-call exec mock setup with declarative mockGHSequence/setupCaptureMock/assertTruncatedBody helpers
10 internal/review/batch_test.go Table-driven, fidelity Consolidate 4 separate TestRunBatch_* functions into table-driven test using real git repo instead of fake temp dirs
11 internal/storage/sync_queries_test.go Parameterized runner Extract testSyncTimestampComparison as a generic test runner, eliminating duplicated timestamp comparison patterns across job/review sync
12 internal/daemon/worker_test.go Helper extraction Add startPool, assertJobStatus, reconfigurePool helpers to workerTestContext, reducing repeated 6-line status-check blocks to single-line calls
13 internal/storage/db_repo_test.go Isolation fix Give each TestBranchPersistence subtest its own DB instead of sharing one DB with manual drain loops between cases
14 internal/githook/githook_test.go Parallelism, helpers Add t.Parallel() throughout; extract assertSubstringsInOrder helper replacing multi-step Index-comparison assertions

Tier 2: Medium Value (some caveats)

# File Pattern Notes
15 internal/daemon/ci_poller_test.go Harness options, assertion helpers, new coverage Largest diff (3042 lines). High value but complex to redo. The now field addition in githubapp.go is a small, clean testability seam worth keeping.
16 internal/storage/db_job_test.go Testify require adoption Mechanical but reduces noise. Extract setupJobEnv helper.
17 internal/storage/db_migration_test.go Named schema constants Extract legacy schema constants and prepareMigratedDB helper.
18 internal/streamfmt/streamfmt_test.go Typed structs for JSON Replace map[string]any JSON construction with proper struct types.
19 internal/daemon/server_ops_test.go Shared assertion helper Introduce assertHandlerStatus helper, extract setupFixJobFixture.
20 cmd/roborev/review_test.go Mock handler helpers Extract setupRepoWithCommits, handleJobsDone, mockEnqueueQueued helpers.
21 cmd/roborev/log_cmd_test.go + internal/streamfmt/render_test.go Test relocation Move TestRenderJobLog_* tests from cmd/roborev/ to the package they actually test.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions