Skip to content

Commit

Permalink
Tests for ZoneFileFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
gerrowadat committed Nov 5, 2023
1 parent 421cd02 commit b67bce2
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions clouddns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,64 @@ func Test_rrsetsEqual(t *testing.T) {
})
}
}

func TestZoneFileFragment(t *testing.T) {
type args struct {
rr *dns.ResourceRecordSet
}
tests := []struct {
name string
args args
want string
}{
{
name: "Empty",
args: args{rr: &dns.ResourceRecordSet{}},
want: "",
},
{
name: "SimpleA",
args: args{rr: &dns.ResourceRecordSet{
Type: "A",
Name: "hostname.example.com.",
Rrdatas: []string{"1.2.3.4"},
}},
want: "hostname.example.com. IN A 1.2.3.4",
},
{
name: "MultipleA",
args: args{rr: &dns.ResourceRecordSet{
Type: "A",
Name: "hostname.example.com.",
Rrdatas: []string{"1.2.3.4", "5.6.7.8"},
}},
want: "hostname.example.com. IN A 1.2.3.4\nhostname.example.com. IN A 5.6.7.8",
},
{
name: "SimpleCNAME",
args: args{rr: &dns.ResourceRecordSet{
Type: "CNAME",
Name: "hostname.example.com.",
Rrdatas: []string{"otherhostname.example.com."},
}},
want: "hostname.example.com. IN CNAME otherhostname.example.com.",
},
{
name: "SimpleCNAMEWithTTL",
args: args{rr: &dns.ResourceRecordSet{
Type: "CNAME",
Name: "hostname.example.com.",
Ttl: 60,
Rrdatas: []string{"otherhostname.example.com."},
}},
want: "hostname.example.com. 60 IN CNAME otherhostname.example.com.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ZoneFileFragment(tt.args.rr); got != tt.want {
t.Errorf("ZoneFileFragment() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit b67bce2

Please sign in to comment.