Skip to content

test(api): assert the RI exchange quote and execute library requests - #1916

Merged
cristim merged 1 commit into
mainfrom
test/ri-exchange-execute-roundtrip
Nov 10, 2026
Merged

cristim merged 1 commit into
mainfrom
test/ri-exchange-execute-roundtrip

Conversation

@cristim

@cristim cristim commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

What

Slice 2 of #1907: round-trip tests for the RI exchange quote (POST /api/ri-exchange/quote) and execute (POST /api/ri-exchange/execute) bodies. The existing tests asserted the audit row or the converter, not the request the handler hands to the exchange library.

Each test sends a full body in both shapes (the targets array and the legacy target_offering_id and target_count) and asserts every field of the library request: region, source RI ids, targets, legacy offering and count, and the execute spend cap. Test-only, no production change.

Verification

  • 14 mutants (each field assignment removed from the two library-request literals, plus value mutants) all fail the new tests; none was a build failure.
  • Pinned golangci-lint v2.10.1: 0 issues; go test ./internal/mocks/ passes.
  • Local review: 2 passes by the same cold reviewer.

Part of #1907

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added coverage for exchange execution and quote requests, verifying that supplied target, region, payment-cap, and legacy request fields are forwarded and remain distinct. This helps catch inconsistencies in how request details are handled.

The execute and quote tests asserted the audit row or only the converter, so a
body field dropped before the exchange library call would go unnoticed. Send
a full body in both shapes (targets array and the legacy singleton fields) and
assert every field of the request the handler hands to the library.

Part of #1907

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cristim cristim added impact/internal Team-internal only type/chore Maintenance / non-user-visible triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-quarter Within the quarter effort/m Days labels Nov 10, 2026
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This pull request adds tests that capture the requests passed by executeExchange and getExchangeQuote to the exchange library. The tests check array-target and legacy-singleton fields, including region and payment cap where supplied.

Changes: Exchange request forwarding

Layer / File(s) Summary
Verify execute and quote request forwarding
internal/api/handler_ri_exchange_execute_roundtrip_test.go
Adds capture tests for both handlers. The tests check array-target fields, separate legacy fields, and that legacy fields are not converted to Targets.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related issues

  • LeanerCloud/cloud-commitments-platform#1907 — The issue identifies missing round-trip tests for quote and execute request bodies at the library boundary. This pull request adds those tests.

Possibly related PRs

Suggested reviewers: iamjsd

Merge Risk: Minimal · up to e9608

The new request-forwarding tests can reach their assertions. No issue identified here needs resolution before merging.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the API tests that verify exchange quote and execute library requests.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7e07088 and e96088e.

Files selected for processing: 1

  • internal/api/handler_ri_exchange_execute_roundtrip_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@cristim
cristim merged commit f6cb123 into main Nov 10, 2026
42 checks passed
@cristim
cristim deleted the test/ri-exchange-execute-roundtrip branch November 10, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant