Skip to content

Test: Give the casefold --by currency test a mixed window - #1238

Merged
huang195 merged 1 commit into
rossoctl:mainfrom
huang195:fix/casefold-test-dead-assertion
Oct 2, 2026
Merged

huang195 merged 1 commit into
rossoctl:mainfrom
huang195:fix/casefold-test-dead-assertion

Conversation

@huang195

@huang195 huang195 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #1179. TestRunCost_ByCurrencyMatchesAUnitSpelledADifferentWay had a second assertion that could not fire on its own fixture.

  • The fixture reported one unit ("currencies":["Credits"]), so windowUnit answered labelled=true and the default: cost = mixedCostCell arm of writeCostBreakdown was unreachable for a priced row.
  • The test's own comment describes the failure it guards as withholding a real unit's figure. That only happens in a window holding more than one unit, so the fixture now reports ["USD","Credits"] with a USD row beside the credits one.
  • The comment says why the fixture is mixed, so the next edit does not simplify it back.

Test-only change: cmd/agentop/cmd_cost_test.go, +7/−2.

Test plan

  • Mutation-checked with isReportedUnit changed to an exact comparison (u == label):
    • old fixture: renders 0.08 Credits; only the first assertion fails;
    • new fixture: renders (mixed); both assertions fail.
  • GOWORK=off go test -count=1 ./... (with SSL_CERT_FILE unset), go vet ./..., gofmt -l . clean in cmd/agentop.

Assisted-By: Claude (Anthropic AI) [email protected]

Summary by CodeRabbit

  • Tests
    • Added test coverage confirming that credit costs are displayed in lowercase as 0.08 credits in a mixed-currency window.

TestRunCost_ByCurrencyMatchesAUnitSpelledADifferentWay asserts that a
unit spelled differently from Snapshot.Currencies keeps its label, and
that it is not withheld as "(mixed)". Its fixture reported a single
unit, ["Credits"], so windowUnit answered labelled=true and
writeCostBreakdown's mixedCostCell arm was unreachable for any priced
row. The second assertion could not fire on any implementation: with
isReportedUnit mutated to an exact comparison the row rendered
"0.08 Credits", which only the first assertion caught.

The fixture now reports ["USD","Credits"] with a USD row beside the
credits one, which is the window the test's own comment describes. The
same mutant now renders "(mixed)" and fails both assertions.

Fixes rossoctl#1179.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 2d1326d9-65a9-435a-b7c5-0c73cfb974f6

📥 Commits

Reviewing files that changed from the base of the PR and between 32c0848 and eb5f33c.

📒 Files selected for processing (1)
  • cmd/agentop/cmd_cost_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.


📝 Walkthrough

Walkthrough

The currency test now uses a mixed-currency window with USD and Credits series. Its assertions continue to check that the lowercase credits row shows 0.08 credits, not a mixed-cost placeholder.

Changes

Cost test fixture

Layer / File(s) Summary
Exercise withholding with mixed currencies
cmd/agentop/cmd_cost_test.go
The fixture adds a USD series alongside the lowercase credits series. Comments explain why the test needs a mixed-currency window. The existing assertion checks that the lowercase row shows 0.08 credits.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other · Severity of issue fixed: Low

Suggested reviewers: abigailgold

Merge Risk: ⚪ Minimal · up to eb5f3

The updated test checks the lowercase Credits row in a mixed-currency window and rejects the mixed-cost placeholder. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: updating the casefold --by currency test to use a mixed-currency window.
Linked Issues check ✅ Passed Issue #1179 requires the (mixed) assertion to use a genuinely mixed window or be removed. This PR keeps the assertion and changes TestRunCost_ByCurrencyMatchesAUnitSpelledADifferentWay to report `…
Out of Scope Changes check ✅ Passed The PR changes only cmd/agentop/cmd_cost_test.go. The changes update the fixture and clarify the test comment for the objective in #1179. No unrelated implementation or test changes are present in t…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

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

@mrsabath mrsabath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the mutation experiment rather than taking the test plan on trust: fetched the branch, changed isReportedUnit to an exact comparison, and confirmed both halves of the claim — the old single-unit fixture renders 0.08 Credits and fails only the first assertion, the new mixed fixture renders (mixed) and fails both. The dead-assertion diagnosis in #1179 is correct and this is the right fix for it.

Tracing the production path agrees: money.WindowUnit returns ok=false only at two or more units, so the old ["Credits"] fixture gave labelled=true and routed every priced row into the case labelled: arm, leaving default: cost = mixedCostCell unreachable.

Fixture arithmetic checks out (146361600 + 77400 = 146439000; 1000 + 57 = 1057), and reusing the $146.3616 figure from writeCostSummary's own comment ties the fixture to the bug it guards. The THE FIXTURE IS MIXED BECAUSE WITHHOLDING NEEDS ONE comment is the part that keeps this fixed — it is the reason the next edit will not simplify the window back to one unit.

go vet and gofmt clean, all 28 CI checks green. Nothing to flag.

@huang195
huang195 merged commit 730b8e4 into rossoctl:main Oct 2, 2026
29 checks passed
@huang195
huang195 deleted the fix/casefold-test-dead-assertion branch October 2, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

abctl: the casefold breakdown test's second assertion is unreachable on its own fixture

2 participants