Skip to content

test: raise coverage to 99% statements, 95% branches - #14

Merged
jacekradko merged 1 commit into
mainfrom
jacek/test-coverage
Sep 3, 2026
Merged

jacekradko merged 1 commit into
mainfrom
jacek/test-coverage

Conversation

@jacekradko

@jacekradko jacekradko commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

The provider layer was at 2% coverage and the Upstash adapter at 0%, which together were most of the gap. This adds suites for both plus the missing branches elsewhere, taking the repo from 72.5% to 99.25% statements and 55.4% to 94.8% branches. Thresholds now gate CI.

The Upstash tests are the part worth a look. All the real logic in that adapter lives in three Lua scripts, so a fake that recorded eval() calls would have asserted nothing. src/__fixtures__/fake-redis.ts bridges redis.call into a Map-backed store and runs the scripts in a Lua VM (wasmoon), which is what makes the limit arithmetic, the stale-reservation sweep and the idempotent settle actually covered. One gotcha is documented in the fixture: returning null from the JS side crashes wasmoon's value bridge, so a missing GET returns undefined and Lua sees nil.

I checked the tests are worth having by mutating the source 36 times and confirming each one goes red. Two survived the first pass and both were my fault, not the code's: the fallback-eligibility test couldn't distinguish mayFallback = true because the second attempt failed at reservation anyway, and the budget idempotency test settled the full reserved amount, where a double-applied settle cancels out exactly. Both are fixed to discriminate.

Branch coverage stops at 94.8% because the remaining five branches are unreachable. Two of them are dead rather than merely defensive: the throw toAiError(lastError) after the attempt loop in run-task.ts can never run, since the last iteration always throws from the catch, and toAiError's ProviderOutputError arm is unreachable because generateWithRepair always converts one first. Left alone, noted beside the thresholds.

Three things surfaced that I filed rather than fixed here, since none are test changes. DD-2541 is a real one: when the paid repair pass is denied a budget reservation, the first call's tokens are released instead of settled, so near a ceiling a tenant retries indefinitely on spend the ledger never sees. That contradicts RunBudget's own docstring. DD-2542 and DD-2543 are smaller.

🤖 Generated with Claude Code

https://claude.ai/code/session_011cCpyfDUJKeTDJAmxFwYSp


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Adds suites for the provider layer and the Upstash adapter, which had 2% and
0% coverage, and fills the untested branches in the runner, registry, spec and
adapters. The Upstash tests execute the adapter's Lua in a wasm VM rather than
asserting that eval() was called, so the limit arithmetic, stale reservation
sweep and idempotent settle are covered for real.

Coverage thresholds now gate CI.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011cCpyfDUJKeTDJAmxFwYSp
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-09-03T15:48:46.535Z

Summary

Metric Count
Packages analyzed 1
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 6f331ee.

@jacekradko
jacekradko merged commit 9be6476 into main Sep 3, 2026
3 checks passed
@jacekradko
jacekradko deleted the jacek/test-coverage branch September 3, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant