Repository navigation
chore: drop duplicate --max-list check and local Azure HTTP mocks - #645
Conversation
The sanity binary validated --max-list twice: once through requireInt32Range and again inline in main(). Remove the inline copy, have the helper compare against math.MaxInt32 instead of 1<<31-1, and split the check into validateInt32Range so it is unit-testable. The error message now keeps the bound and offending value the inline copy used to print. The cache, cosmosdb, database and search client tests declared their own MockHTTPClient and createMockHTTPResponse. Delete those copies and use mocks.MockHTTPClient and mocks.CreateMockHTTPResponse from providers/azure/mocks, as compute, managedredis and synapse already do. Closes LeanerCloud#644 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: rF2. 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. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Local verification at |
Root cause and fix
Two leftovers from platform issues whose platform parts are already done (A14-040 and A15-007).
1. Duplicate
--max-listrange check (ci_cd_sanity_tests/cmd/sanity/main.go)main()calledrequireInt32Range("--max-list", *maxList)and then ran the same bound check again inline. This PR:math.MaxInt32instead of1<<31-1.validateInt32Range(flagName, n) error, so it can be unit-tested withoutos.Exit.requireInt32Rangestill prints and exits with code 2.The
mathimport is still used by the helper. The helper's message now includes the bound and the offending value, which the deleted inline copy used to print, so no diagnostic is lost. Theint32(*maxList)conversion and its#nosec G115justification are unchanged and remain valid.2. Local copies of the shared Azure HTTP mock
providers/azure/services/{cache,cosmosdb,database,search}/client_test.goeach declared their ownMockHTTPClientandcreateMockHTTPResponse. This PR deletes those copies and switches every call site tomocks.MockHTTPClientandmocks.CreateMockHTTPResponsefromproviders/azure/mocks, which compute, managedredis and synapse already use.All four files already imported that package, so no import changes were needed. The shared double does the same thing as the deleted copies:
m.Called(req), nil→error, otherwise the response. The only difference is that it panics with a clearer message on a wrong type instead of a bare type-assertion panic. NoTest*functions were removed.Closes #644
Verification
All of this is local unit evidence. No cloud calls were made. The sanity binary exits on flag validation before
aws.Run. Environment for every command:AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true, Go 1.26.10.ci_cd_sanity_tests:go build ./...,go vet ./...andgo vet -tags integration ./...all pass.providers/azure:go build ./...,go vet ./...andgo vet -tags integration ./...all pass.ok:go test -count=1 ./cmd/sanity/(newTestValidateInt32Range: 0, -1, 1, 5, MaxInt32, MaxInt32+1)go test -count=1 ./services/cache/go test -count=1 ./services/cosmosdb/go test -count=1 ./services/database/go test -count=1 ./services/search/run --allow-parallel-runnersreports 0 issues in both modules:providers/azureon./services/{cache,cosmosdb,database,search}/andci_cd_sanity_testson./cmd/sanity/.gocyclo -over 10 -ignore "_test\.go" ci_cd_sanity_tests/cmd/sanity/main.goproduces no output.gofmt -lon the touched files produces no output.grep -rn "type MockHTTPClient\|func createMockHTTPResponse" providers/) now finds onlyproviders/azure/mocks/azure_mocks.go.Fail-before / pass-after. This is a refactor with no behavior bug, so the honest "before" evidence is limited to the following:
main.go, the build fails withundefined: validateInt32Range. The helper was not testable before.--max-list=0and--max-list=2147483648, it printedERROR: --max-list must be between 1 and math.MaxInt32and exited with rc=2. After, it printsERROR: --max-list must be between 1 and 2147483647, got 0(orgot 2147483648) and still exits with rc=2.Parent verification at
5de4e1c(branch is up to date with main):go test -race -short -count=1 ./...passes in theci_cd_sanity_testsandproviders/azuremodules. This is the only branch for its modules in this batch; go#643 touches different files.Out of scope
Labels
Maintainer: please mirror the issue's triage labels onto this PR:
type/chore,priority/p3. The issue has notriagedlabel.🤖 Generated with Claude Code