Repository navigation
test(server): fold mockConfigStoreForHealth onto mocks.MockConfigStore - #1460
Conversation
First half of folding the hand-rolled health-test store onto the shared mock (LeanerCloud#76). The type now embeds mocks.MockConfigStore and drops 68 of its ~150 hand-written stubs, which the embedded defaults now serve. CleanupOldExecutions and GetStaleProcessingExchanges stay: the shared mock requires an expectation for them, and the scheduled-task tests here call them without one. The type still defines more than half of StoreInterface, so it stays on the guard's allowlist until the next commit removes the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rHealth Finishes folding the health-test store onto mocks.MockConfigStore (LeanerCloud#76). The 80 remaining hand-written stubs are gone. Only the two overrides the server tests need are left, so a new StoreInterface method no longer needs a stub here. The type no longer hand-rolls the interface, so it comes off the guard's allowlist, which is now empty: any new hand-rolled copy fails TestNoHandRolledConfigStoreMocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rE2. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
Conflicted file: - internal/server/test_helpers_test.go: main (LeanerCloud#1240) added a hand-written ListStoredRecommendationsChunk stub returning RecommendationChunk{Done: true} to the old hand-rolled mockConfigStoreForHealth. This branch replaces that type with an embed of mocks.MockConfigStore, whose ListStoredRecommendationsChunk already returns RecommendationChunk{Done: true}, nil when no expectation is set. Kept the branch's shared-mock version with only its two overrides and dropped the stub, since the embedded mock gives the same default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged Conflict: Checks:
|
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked: The risk in a refactor like this is that tests keep passing vacuously because Body-stale:
Reviewer: rE5. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 1 approving independent review(s) on |
LeanerCloud#1460 replaced the hand-written mockConfigStoreForHealth with the shared mocks.MockConfigStore, which already has GetExecutionsByStatusesFiltered, so take main's test_helpers_test.go and drop this branch's stub method. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LeanerCloud#1460 replaced the hand-written mockConfigStoreForHealth with the shared mocks.MockConfigStore, which already has ListMarketplaceListingsToPoll, RecordMarketplaceListingActive and SettleMarketplaceListing, so take main's test_helpers_test.go and drop this branch's stub methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #76
Why
internal/server'smockConfigStoreForHealthstubbed all ~150config.StoreInterfacemethods by hand. Every new store method needed another stub there. That per-method tax is what #76 is about, and the type was the last entry onhandRolledConfigStoreAllowlistin the hand-rolled-copy guard.What
internal/server/test_helpers_test.go:mockConfigStoreForHealthnow embedsmocks.MockConfigStore. Only two overrides are left,CleanupOldExecutionsandGetStaleProcessingExchanges, both returning "nothing". The shared mock panics on those two without an expectation, and the scheduled-task tests here (handleCleanupExpiredRecords,alarmStaleRIExchanges) call them without one. The embedders inhandler_ladder_test.goandhandler_ri_exchange_test.gocompile and pass unchanged.internal/mocks/config_store_copies_guard_test.go:handRolledConfigStoreAllowlistis now empty, soTestNoHandRolledConfigStoreMocksrejects any new hand-rolled copy.How I picked the two overrides: before the change, I called every
StoreInterfacemethod on both the old hand-rolled type and a bareMockConfigStorethrough reflection, with zero arguments. 86 methods differed, 75 of them because the shared mock panics without an expectation. I then ran theinternal/serversuite (unit, and-race -tags integration) against the embedded mock with no overrides. I added back the old default only for methods a test actually reached, and only those two came up. The comparison script was throwaway and is not committed.What remains on #76
MockHTTPClientin the cache, cosmosdb, database and search client tests) lives inLeanerCloud/cloud-commitments-go(providers/azure), not in this repo, so it needs a PR there.internal/analytics/collector_test.go'smockConfigStore. It already embedsmocks.MockConfigStoreon main, so nothing is left to do for it.Verification
test_helpers_test.gofails withhand-rolled config.StoreInterface test doubles ...: internal/server.mockConfigStoreForHealth. Main's guard (allowlist still set) against the new helper fails withinternal/server.mockConfigStoreForHealth no longer hand-rolls config.StoreInterface; remove it from handRolledConfigStoreAllowlist. Both pass after.go build ./... && go vet ./... && go vet -tags integration ./... && (cd tests/e2e && go vet -tags e2e ./...): pass.golangci-lintv2.10.1 on./internal/server/... ./internal/mocks/..., with and without--build-tags integration: 0 issues. No non-test files changed, so gocyclo doesn't apply.go test -race -short -count=1 ./internal/server/ ./internal/mocks/: ok, at both commits.go test -race -tags integration -count=1 ./internal/server/: on the first full run everything passed exceptTestEnsureDB_IsLambdaSingleSourceOfTruth(template clone timed out) andTestCheckConfigStore_DBFailureHidesRawError(Postgres container start timed out), both on a heavily loaded shared host. On rerun, the first passed once and the second passed three times in a row.scripts/test-git-secrets-allowlist.sh: 183 PASS, 0 FAIL.🤖 Generated with Claude Code