Skip to content

test(cost): add unit test for max_daily_cents=0 unlimited budget behavior #2110

@bug-ops

Description

@bug-ops

Summary

PR #2109 fixed the cost budget guard so that max_daily_cents=0 means unlimited (no budget restriction), via:

if self.max_daily_cents > 0.0 && state.spent_cents >= self.max_daily_cents {

However, no unit test covers this case. The existing tests use max_daily_cents = 0.01 (budget exceeded) and max_daily_cents = 100.0 (under limit) but never max_daily_cents = 0.0 (unlimited).

Expected behavior

CostTracker::new(true, 0.0).check_budget() should always return Ok(()) regardless of how much has been spent.

Proposed test

#[test]
fn check_budget_unlimited_when_max_daily_cents_is_zero() {
    let tracker = CostTracker::new(true, 0.0);
    tracker.record_usage("claude-opus-4-20250514", 100_000, 100_000);
    assert!(tracker.check_budget().is_ok());
}

Severity: LOW — the fix is correct. This is purely a coverage gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions