Skip to content

Commit

Permalink
Merge pull request #4462 from leonardocaylent/bugfix/add-clarificatio…
Browse files Browse the repository at this point in the history
…n-to-endpoint-unit-tests

fix: add clarification to endpoint unit tests
  • Loading branch information
k8s-ci-robot authored May 16, 2024
2 parents 6d67d6e + 08e9177 commit fe64736
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions endpoint/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestIsLess(t *testing.T) {
}
}

func TestFilterEndpointsByOwnerID(t *testing.T) {
func TestFilterEndpointsByOwnerIDWithRecordTypeA(t *testing.T) {
foo1 := &Endpoint{
DNSName: "foo.com",
RecordType: RecordTypeA,
Expand All @@ -162,15 +162,71 @@ func TestFilterEndpointsByOwnerID(t *testing.T) {
},
}
foo2 := &Endpoint{
DNSName: "foo2.com",
RecordType: RecordTypeA,
Labels: Labels{
OwnerLabelKey: "foo",
},
}
bar := &Endpoint{
DNSName: "foo.com",
RecordType: RecordTypeA,
Labels: Labels{
OwnerLabelKey: "bar",
},
}
type args struct {
ownerID string
eps []*Endpoint
}
tests := []struct {
name string
args args
want []*Endpoint
}{
{
name: "filter values",
args: args{
ownerID: "foo",
eps: []*Endpoint{
foo1,
foo2,
bar,
},
},
want: []*Endpoint{
foo1,
foo2,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FilterEndpointsByOwnerID(tt.args.ownerID, tt.args.eps); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ApplyEndpointFilter() = %v, want %v", got, tt.want)
}
})
}
}

func TestFilterEndpointsByOwnerIDWithRecordTypeCNAME(t *testing.T) {
foo1 := &Endpoint{
DNSName: "foo.com",
RecordType: RecordTypeCNAME,
Labels: Labels{
OwnerLabelKey: "foo",
},
}
foo2 := &Endpoint{
DNSName: "foo2.com",
RecordType: RecordTypeCNAME,
Labels: Labels{
OwnerLabelKey: "foo",
},
}
bar := &Endpoint{
DNSName: "foo.com",
RecordType: RecordTypeA,
RecordType: RecordTypeCNAME,
Labels: Labels{
OwnerLabelKey: "bar",
},
Expand Down

0 comments on commit fe64736

Please sign in to comment.