Fix QA nits from PR #8 #29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/qa-nits-pr8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
(*APIError)type assertions witherrors.Asfor consistent error unwrapping across all test filesotherTXTvariable and no-opretryOn429call inTestReplaceRecordsByTypeTestReplaceAllRecords— use explicitmake/copyto avoid mutating the backing arraydomaininTestGetDomainReplaceRecordsByTypetest only preserves@TXT records, non-@names will be droppedChanges
pkg/godaddy/dns_test.goerrors.Asconsistency (3 sites), dead code removal, slice safety, TXT gap commentpkg/godaddy/domains_test.goTest Plan
go build ./...passesgo vet ./...passesgo test ./pkg/godaddy/ -vwith credentials (live API — same as PR #8)Review Checklist
errors.Aspattern matchesclient_test.goretryOn429helperRelated Notes
Closes #10
PR #29 Review
DOMAIN REVIEW
Stack: Go test files for a GoDaddy API client (
pkg/godaddy/). Applying Go idiom, error handling, and test quality checks.1.
errors.Asmigration (dns_test.go, 3 sites) -- Correct and necessaryThis is not merely a style preference. The
APIErroris returned as*APIErrorfromclient.do(), butGetRecords(and other client methods) wrap it viafmt.Errorf("getting records for %s %s.%s: %w", ...). The%wverb wraps the error in a chain. A direct type assertionerr.(*APIError)would fail on wrapped errors;errors.Asunwraps the chain. This fix prevents a class of silent test bugs where a 404 would not be recognized and the test would fail spuriously.The pattern now matches
retryOn429inclient_test.go(line 55), which already usederrors.As. Consistency restored.2. Dead code removal (dns_test.go) -- Clean
The
otherTXTvariable, its no-opretryOn429call, and the_ = otherTXTsuppression line are all removed together. No dangling references remain. The block was literally a no-op (the closure setotherTXT = niland returnednil).3. TXT preservation gap comment (dns_test.go) -- Accurate
The comment correctly documents that
TestReplaceRecordsByTypeonly preserves@TXT records because it callsGetRecords(ctx, testDomain, "TXT", "@"). Non-@TXT names (e.g.,_dmarc,_domainconnect) are silently dropped. This is a real production risk and the comment is a useful artifact for the future fix.4. Slice safety fix (dns_test.go,
TestReplaceAllRecords) -- CorrectOld code:
replacement := append(existing, ...)-- ifexistinghas spare backing-array capacity,appendmutates the original slice's memory. The newmake/copy/appendpattern is the standard Go idiom for this. Note: this test is behindt.Skipso the risk was low, but the fix is still correct for when the skip is removed.5. Nil guard (domains_test.go,
TestGetDomain) -- CorrectGetDomainreturns(*Domain, error). If both are nil (unexpected but possible), the original code would panic ondomain.Domain. The nil guard witht.Fatalfails fast with a clear message.errorsimport addition (dns_test.go) -- CorrectThe
"errors"import is added at line 4 in sorted position within the stdlib block. Matchesgoimportsconventions.BLOCKERS
None.
NITS
Test Plan checkbox: The PR body shows
go test ./pkg/godaddy/ -vas unchecked. This is expected since it requires live API credentials, but worth noting it was not run as part of this PR.TXT gap is a known tech-debt item: The comment documents the problem well. Consider tracking it as a separate issue so it does not get lost (low priority, not blocking this PR).
SOP COMPLIANCE
## Summary-- yes## Changes-- yes, with a table## Test Plan-- yes, with checkboxes## Related-- yes (Related Notessection references PR #8, closes #10).envfiles, or credentials committedPROCESS OBSERVATIONS
errors.Asfix is the most impactful change here. Without it, wrapped errors fromGetRecordswould silently bypass the 404 check, causing test flakiness against the live API. Good catch in the original review.VERDICT: APPROVED