Add integration tests for pkg/godaddy/ client #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/integration-tests"
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
Changes
pkg/godaddy/client_test.go: test helpers (testClientwith env-based skip,retryOn429for 429 backoff),TestNewClient,TestNewClientWithBaseURL, record name/data helperspkg/godaddy/dns_test.go: integration tests for all 6 DNS methods —TestGetRecords(NS@),TestAddAndDeleteRecords,TestReplaceRecords,TestReplaceRecordsByType,TestReplaceAllRecords(skipped by default as destructive)pkg/godaddy/domains_test.go: integration tests forTestListDomainsandTestGetDomainagainst palinks.appTest Plan
_test-godaddy-tofu-*prefix to avoid DNS conflictsgo build ./...andgo vet ./...cleanReview Checklist
Related Notes
godaddy-tofu— custom OpenTofu provider for GoDaddy APIPR #8 Review
DOMAIN REVIEW
Tech stack: Go (standard library
testing,context,encoding/json,errors,os,time,strconv). Integration tests for a Go API client (pkg/godaddy/). No frameworks -- pure stdlib test patterns.Coverage: All 6 DNS methods (
GetRecords,AddRecords,DeleteRecords,ReplaceRecords,ReplaceRecordsByType,ReplaceAllRecords) and both domain methods (ListDomains,GetDomain) are tested. This matches the full public API surface of the client. Good.Test design: Tests run against the live GoDaddy API with
testClientgating on env vars.retryOn429handles rate limiting with parsed backoff.t.Cleanupensures idempotent teardown. TXT records use_test-godaddy-tofu-*prefix with nonce data (UnixNanobase-36) for isolation. DestructiveReplaceAllRecordsis correctly skipped by default.BLOCKERS
None.
NITS
Error type assertion inconsistency (
dns_test.go,TestAddAndDeleteRecords, post-delete verification): TheretryOn429helper correctly useserrors.As(err, &apiErr)to unwrap wrapped errors. But the 404 check after the retry block uses a direct type assertion:getErr.(*APIError). Since the client wraps errors withfmt.Errorf("...: %w", err), a direct assertion will fail to match a wrapped*APIError. Useerrors.Asconsistently:This same inconsistency appears in
TestReplaceRecordsByTypewhere a direct assertionerr.(*APIError)is used for the 404 check on existing record reads.Dead code in
TestReplaceRecordsByType(dns_test.go): TheotherTXTvariable is declared, populated via a no-opretryOn429call (the closure just setsotherTXT = nil; return nil), and then discarded with_ = otherTXT. This is ~10 lines of dead code with an explanatory comment. Either remove it entirely or add a// TODOif there is a future plan to fetch all TXT names.Slice append gotcha in
TestReplaceAllRecords(dns_test.go):replacement := append(existing, DNSRecord{...})may mutate the backing array ofexistingif it has spare capacity. Safer pattern:Since this test is skipped by default, this is low priority but worth fixing before anyone uncomments the skip.
Nil dereference risk in
TestGetDomain(domains_test.go): The test callsc.GetDomain(ctx, testDomain)and immediately accessesdomain.Domainwithout checking ifdomainis nil. If the API returns an unexpected empty response, this panics instead of producing a clear test failure. Add a nil guard:TestReplaceRecordsByTypeonly preserves@TXT records: The test readsexistingTXTviaGetRecords(ctx, testDomain, "TXT", "@")before callingReplaceRecordsByTypewhich replaces ALL TXT records for the domain. TXT records with names other than@and the test name will be dropped. The deadotherTXTcode acknowledges this gap. Consider adding a comment explicitly documenting this risk, or querying additional known TXT names.SOP COMPLIANCE
PROCESS OBSERVATIONS
retryOn429pattern with body-parsed backoff is more robust than fixed-delay retry -- good engineering.TestReplaceAllRecordsby default is the correct call for a destructive operation against a live domain.VERDICT: APPROVED