test(cli): assert claim-on-login surfaces claimed-token count#26
Merged
Conversation
The CLI claims anonymous resources as a side effect of the login
device-flow (POST /auth/cli -> poll GET /auth/cli/{id} -> claimed_tokens).
Existing runLogin tests let the claim-print branch run but assert only
err == nil and discard stdout, so they never prove the user-visible
"N anonymous resource token(s) claimed" output is correct (CLAUDE.md
rule 12: verification surface must match the failure surface).
Adds claim_login_test.go covering the user-visible claim surface against
an httptest device-flow stub:
- multi-token claim: asserts the rendered count line + credential persistence
- zero-token claim: asserts NO claim line is printed (avoids "0 ... claimed")
- pending-then-success: claim count survives the 202-then-200 multi-poll path
Mirrors the existing httptest stub + withCleanState/withTestAPI/
withShortPolls/captureStdout helpers; named constants, no inline strings.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
cmd/claim_login_test.go— integration coverage for the CLI claim path.The CLI has no standalone
claimcommand. Anonymous resources are claimed as a side effect of the login device-flow:POST /auth/cli→ pollGET /auth/cli/{id}→ on success the response carriesclaimed_tokens, andrunLoginprints"N anonymous resource token(s) claimed to your account."(login.go:115-116).Why (the gap)
The existing suite already covers the poll helpers (
login_poll_test.go,login_timeout_test.go,coverage_login_test.go) and therunLoginhappy/error branches (coverage_push95_test.go). But everyrunLogintest asserts onlyerr == niland discards stdout — the claim-print branch runs but is never read. A greenrunLoginis therefore not proof the user actually sees their claimed-token count.Per CLAUDE.md rule 12 ("Shipped ≠ Verified": the verification surface must match the failure surface), this PR closes that gap by capturing stdout and asserting the rendered claim output.
New cases (vs already-covered)
"2 ... claimed to your account."line and credentials persisted to configAll three mirror the existing httptest stub +
withCleanState/withTestAPI/withShortPolls/captureStdouthelpers. Named constants, no inline string literals.Gate
cmd-package coverage: 95.5% (above 95% floor). Diff is test-only; the targeted claim-print branch is covered.
🤖 Generated with Claude Code