Skip to content

test(api): align scope matrix fixtures with the #416 approve API - #440

Merged
cristim merged 1 commit into
mainfrom
fix/main-scope-matrix-mocks
Sep 28, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/main-scope-matrix-mocks

Conversation

@cristim

@cristim cristim commented Sep 28, 2026

Copy link
Copy Markdown
Member

Summary

Fixes red main (Unit Tests and Integration Tests) after the #381 merge. Test-only change in internal/api/execution_scope_test.go.

Root cause

Emergent conflict between #416 and #381, each green alone. #416 changed ApproveAndExecute / RunPlannedPurchaseNow to return (string, error) and stores approval tokens hashed. #381's matrix test stubbed both with Return(errScopeTestReached) (one value), so MockPurchaseManager panicked on args.String(0) ("mutation reached"). Behind that panic, TestRevoke_AuthorizedNonRevocableStatusIs409 stored the raw "email-token", so its token cases got 403 instead of 409.

Fix

  • Both stubs now Return("", errScopeTestReached).
  • The revoke fixture stores config.HashApprovalToken("email-token").

Regression proof

  • origin/main: go test -race -short -run TestExecutionEndpoints_ScopeMatrix ./internal/api/ panics as above; with the fix it passes.
  • Matrix still has teeth: temporarily making requireExecutionAccess return nil yields 55 failing subtests (all partial/out-of-scope deny cases). Reverted.

Verification

  • go test -race -short ./internal/api ./internal/server ./internal/mocks: all ok (go1.26.6).
  • golangci-lint v2.10.1 run ./...: 0 issues. go vet ./...: clean. gocyclo -over 10 -ignore "_test\.go" .: no output.

Closes #439

#381 and #416 merged back to back and were each green alone. #416 made
ApproveAndExecute and RunPlannedPurchaseNow return (string, error) and
stores approval tokens hashed, so the #381 matrix test panicked on its
single-value mock returns and its revoke fixture stored a raw token.

Closes #439
@cristim cristim added priority/p1 Next up; this sprint type/bug Defect severity/high Significant harm urgency/now Drop other things effort/xs Trivial / one-liner labels Sep 28, 2026
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 1 billable file and costs up to $0.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 33 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 62 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: e978af3b-a933-432d-a30d-ee7e642c8169

📥 Commits

Reviewing files that changed from the base of the PR and between fbe9596 and a238002.

📒 Files selected for processing (1)
  • internal/api/execution_scope_test.go

Comment @coderabbitai help to get the list of available commands.

@cristim

cristim commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

Orchestrator-verified test-only fix for red main (emergent #416 x #381 conflict): the two matrix stubs return the post-#416 (string, error) shape, and the revoke fixture stores the hashed token. The author proved the matrix still has teeth (55 deny subtests fail with requireExecutionAccess forced to nil); go test -race -short api/server/mocks, golangci-lint v2.10.1, vet and gocyclo are clean; CI green.

@cristim
cristim merged commit fb19eaa into main Sep 28, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner priority/p1 Next up; this sprint severity/high Significant harm type/bug Defect urgency/now Drop other things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main red: scope matrix mocks use the pre-#416 approve signature

1 participant