Refactor A/AAAA blank content to dynamic Dynu semantics

This commit is contained in:
beatz174-bit committed 2026-04-29 09:13:54 +10:00
1 parent 0319ce65fd
commit 8727989db9
10 files changed
+402 -97

No files matched your search

+2 -27
View File
@@ -192,7 +192,7 @@ func testAccCreateRecordMaybeSkipUnsupported(t *testing.T, client *dynuclient.Cl
}
var apiErr *dynuclient.APIError
if errors.As(err, &apiErr) && isUnsupportedEmptyContentAPIError(apiErr) {
if errors.As(err, &apiErr) && isUnsupportedEmptyContentError(apiErr) {
t.Skipf("Dynu account/API does not support %s in this environment (%v)", scenario, err)
}
@@ -222,31 +222,6 @@ func testAccDeleteRecord(t *testing.T, client *dynuclient.Client, domainID int64
}
}
func isUnsupportedEmptyContentAPIError(apiErr *dynuclient.APIError) bool {
if apiErr == nil || apiErr.StatusCode != 400 {
return false
}
normalizedType := strings.ToLower(strings.TrimSpace(apiErr.Type))
if normalizedType != "validation exception" {
return false
}
normalizedMessage := strings.ToLower(strings.TrimSpace(apiErr.Message))
knownUnsupportedMessages := []string{
"content is required",
"ipv4address is required",
"ipv6address is required",
}
for _, fragment := range knownUnsupportedMessages {
if strings.Contains(normalizedMessage, fragment) {
return true
}
}
return false
}
func TestIsUnsupportedEmptyContentAPIError(t *testing.T) {
t.Parallel()
@@ -297,7 +272,7 @@ func TestIsUnsupportedEmptyContentAPIError(t *testing.T) {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
if got := isUnsupportedEmptyContentAPIError(tc.err); got != tc.expect {
if got := isUnsupportedEmptyContentError(tc.err); got != tc.expect {
t.Fatalf("unexpected result for %q: got %v, want %v", tc.name, got, tc.expect)
}
})