Skip to content

chore: fix unchecked errors in test setup and assertions #73

Description

@sonupreetam

Context

Review council on PR #61 flagged systematic unchecked errors in test setup and assertion code across multiple test files. These are pre-existing issues, not regressions from #61.

Files

  • cmd/replicator/init_test.goos.MkdirAll, os.WriteFile, os.ReadFile errors discarded
  • cmd/replicator/serve_test.goos.MkdirAll, os.WriteFile errors discarded
  • internal/gitutil/git_test.goWorktreeAdd, os.WriteFile, Run errors discarded
  • internal/forge/worktree_test.goWorktreeCreate, os.WriteFile, Run errors discarded
  • internal/forge/init_test.go, spawn_test.go, review_test.go, progress_test.go, insights_test.goDB.Exec, DB.QueryRow().Scan() errors discarded
  • internal/mcp/server_test.gojson.Unmarshal errors discarded in assertions
  • test/parity/parity_test.gojson.Unmarshal errors discarded in setup

Pattern

Replace os.WriteFile(path, data, 0o644) with:

if err := os.WriteFile(path, data, 0o644); err != nil {
    t.Fatalf("setup WriteFile: %v", err)
}

The fix in internal/agentkit/agentkit_test.go (PR #61) shows the correct pattern.

Additional items

  • cmd/replicator/init_test.go:TestRunInit_ForceOverwrites uses a negative-only assertion (checks content is different but not what it should be). Should assert equality with embedded content.
  • internal/forge/worktree_test.go has no test for the cleanupAll=true branch of WorktreeCleanup, contributing to CRAP score 65.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanupCode hygiene and technical debt

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions