Skip to content

test: consolidate hand-rolled ConfigStore mocks (3 copies, taxes every new store method) #76

Description

@cristim

Duplication audit: 3 hand-rolled config.StoreInterface mocks (internal/mocks/stores.go MockConfigStore, internal/analytics/collector_test.go mockConfigStore, internal/server/test_helpers_test.go mockConfigStoreForHealth) must each gain a stub for EVERY new StoreInterface method - L5 alone had to touch all 3 for 2 new methods; this recurs on LeanerCloud/cloud-commitments-cli#1362/#1368/etc. Consolidate: have the smaller mocks embed mocks.MockConfigStore (override only what they exercise), or split StoreInterface into role interfaces. Reduces the per-method tax + the interface-widening-completeness-trap surface.

Findings from the 2026-09-02 codebase audit

Added by an automated audit of 3c0f8ac94048a2c36fce5ccddee54e6c4849a5cd (tip of origin/main). Each item below was reported by one reviewer and independently confirmed by a second that did not write it. Full report: docs/audits/codebase-audit-2026-09-02.md.

A15-007 (low)

A second instance of this tax, and it is already split down the middle. providers/azure/mocks exports MockHTTPClient and CreateMockHTTPResponse, and compute, managedredis and synapse import them (51, 41 and 28 references respectively). Four sibling service test files redeclare a local copy instead and reference the shared ones zero times: cache/client_test.go:94, cosmosdb/client_test.go:104, database/client_test.go:87 and search/client_test.go:92. So a behaviour change to the shared double -- adding call recording, or a Do that honours ctx -- silently reaches three services and misses four. The copies are not byte-identical either: the shared type also carries ResponseBody string and StatusCode int (azure_mocks.go:123-124), and only the Do method and the response helper match verbatim, which if anything strengthens the drift argument. Deleting the four local copies and importing the shared package is the same move this issue proposes for the ConfigStore mocks. (audit finding A15-007)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions