test: cover domain requirements and claims - #30
Merged
Conversation
runClaims and joinYears were at 0.0% and runRequirements at 56.2% — the
whole file 25.7%, now 90.5%. These are the commands that tell someone
what a registry demands before they try to register, so being wrong here
surfaces as a failed registration rather than as a bad table.
29 cases. What they pin, and why each one is worth a test:
- The TLD is canonicalized into the request path (" FR " -> "fr"). The
API wants it bare, lowercase and ASCII; ".FR" 404s.
- A blank TLD is rejected before any HTTP call, against a server that
fails the test if contacted.
- Quiet mode lists the required *field names*, sorted. Sorting is not
cosmetic: Go randomizes map iteration, so unsorted output differs run
to run and nothing built on it is reproducible. The test asserts exact
order, and dropping sort.Strings fails it.
- Quiet mode prints nothing when a TLD requires no fields, rather than
echoing the TLD back.
- The capability table renders both a true and a false flag, so a badge
stuck on one value cannot pass.
- The table keeps its pointers to `-o json` and `--tld-requirement`;
without them the nested requirements are unreachable from the default
view, which is the whole reason they are printed as a hint.
- claimId "" counts as unclaimed, not claimed. The distinction decides
whether someone is told to pass --acknowledge-claim.
- An inactive claims process is stated explicitly — "no claims found"
means something different when nothing was checked.
- JSON and YAML carry the nested requirements and the claim id, and omit
the human hint.
- A 404 surfaces the API's message.
Verified by mutation, seven of them, all caught: dropping the sort,
changing joinYears' empty placeholder and its separator, treating a
non-nil empty claimId as claimed, inverting the claims-process notice,
skipping canonicalization, and silencing the quiet-mode claim id.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
runClaimsandjoinYearswere at 0.0%,runRequirementsat 56.2% — the file overall 25.7% → 90.5%.These are the commands that tell someone what a registry demands before they try to register, so being wrong here surfaces as a failed registration rather than as a bad-looking table.
runRequirementsrunClaimsjoinYearsRepo total: 67.2% → 68.3%.
What the 29 cases pin
" FR "→fr). The API wants it bare, lowercase, ASCII;.FR404s.-o jsonand--tld-requirementpointers. Without them the nested requirements are unreachable from the default view — which is the entire reason they're printed as a hint instead of flattened into a misleading table.claimId: ""counts as unclaimed, not claimed. That distinction decides whether someone is told to pass--acknowledge-claim.Verification
Seven mutations, all caught:
sort.Stringsin quiet modejoinYearsempty placeholderjoinYearsseparatorclaimIdas claimed-vgolangci-lint run— no issuesgo test -race -count=1 ./...— full suite cleango vet ./...cleanRemaining, if you want to keep going
cmd/dns,cmd/url,cmd/emailsit at ~66–71% with the same shape of gap — error paths the existing stubs never drive. That's mechanical volume work rather than thinking work.Still worth an explicit decision rather than drift:
cmd/help.go,cmd/cmdutil/complete.goandinternal/updateare 0% but are help text, shell completion, and a network version check — roughly 6 points of badge for very little confidence.