Skip to content

Instantly share code, notes, and snippets.

@david-martin
Last active August 11, 2022 14:23
Show Gist options
  • Save david-martin/03a1ec2fc78009383a42d574da96a7fc to your computer and use it in GitHub Desktop.
Save david-martin/03a1ec2fc78009383a42d574da96a7fc to your computer and use it in GitHub Desktop.
diff --git a/pkg/util/dns/dns_record_test.go b/pkg/util/dns/dns_record_test.go
index 933b9ca..85ce9bd 100644
--- a/pkg/util/dns/dns_record_test.go
+++ b/pkg/util/dns/dns_record_test.go
@@ -1,17 +1,16 @@
package dns
import (
- "errors"
- v1 "github.com/kuadrant/kcp-glbc/pkg/apis/kuadrant/v1"
"testing"
+
+ v1 "github.com/kuadrant/kcp-glbc/pkg/apis/kuadrant/v1"
)
func TestIsValidDNSRecord(t *testing.T) {
tests := []struct {
name string
dnsRecord *v1.DNSRecord
- wantErr error
- verify func(wantErr error, t *testing.T)
+ verify func(err error, t *testing.T)
}{
{
name: "dns record has one endpoint",
@@ -20,9 +19,9 @@ func TestIsValidDNSRecord(t *testing.T) {
Endpoints: []*v1.Endpoint{
&v1.Endpoint{},
}}},
- verify: func(wantErr error, t *testing.T) {
- if wantErr != nil {
- t.Errorf("expected nil errors, got: %v", wantErr)
+ verify: func(err error, t *testing.T) {
+ if err != nil {
+ t.Errorf("expected nil errors, got: %v", err)
}
},
},
@@ -35,9 +34,9 @@ func TestIsValidDNSRecord(t *testing.T) {
},
},
},
- verify: func(wantErr error, t *testing.T) {
- if wantErr != nil {
- t.Errorf("expected nil errors, got: %v", wantErr)
+ verify: func(err error, t *testing.T) {
+ if err != nil {
+ t.Errorf("expected nil errors, got: %v", err)
}
},
},
@@ -46,9 +45,9 @@ func TestIsValidDNSRecord(t *testing.T) {
dnsRecord: &v1.DNSRecord{
Spec: v1.DNSRecordSpec{},
},
- verify: func(wantErr error, t *testing.T) {
- if wantErr != errors.New("no Endpoints set - DNS Record has 0 or nil Endpoints") {
- t.Errorf("expected no Endpoints set - DNS Record has 0 or nil Endpoints, got: %v", wantErr)
+ verify: func(err error, t *testing.T) {
+ if err.Error() != "no Endpoints set - DNS Record has 0 or nil Endpoints" {
+ t.Errorf("expected no Endpoints set - DNS Record has 0 or nil Endpoints, got: %v", err)
}
},
},
@@ -59,18 +58,17 @@ func TestIsValidDNSRecord(t *testing.T) {
Endpoints: []*v1.Endpoint{},
},
},
- verify: func(wantErr error, t *testing.T) {
- if wantErr != errors.New("no Endpoints set - DNS Record has 0 or nil Endpoints") {
- t.Errorf("expected no Endpoints set - DNS Record has 0 or nil Endpoints, got: %v", wantErr)
+ verify: func(err error, t *testing.T) {
+ if err.Error() != "no Endpoints set - DNS Record has 0 or nil Endpoints" {
+ t.Errorf("expected no Endpoints set - DNS Record has 0 or nil Endpoints, got: %v", err)
}
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- IsValidDNSRecord(tt.dnsRecord)
- tt.verify(tt.wantErr, t)
-
+ err := IsValidDNSRecord(tt.dnsRecord)
+ tt.verify(err, t)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment