Merge pull request #4462 from leonardocaylent/bugfix/add-clarification-to-endpoint-unit-tests

fix: add clarification to endpoint unit tests
This commit is contained in:
Kubernetes Prow Robot 2024-05-16 01:31:28 -07:00 committed by GitHub
commit fe6473618c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,
@ -162,8 +162,8 @@ func TestFilterEndpointsByOwnerID(t *testing.T) {
},
}
foo2 := &Endpoint{
DNSName: "foo.com",
RecordType: RecordTypeCNAME,
DNSName: "foo2.com",
RecordType: RecordTypeA,
Labels: Labels{
OwnerLabelKey: "foo",
},
@ -209,6 +209,62 @@ func TestFilterEndpointsByOwnerID(t *testing.T) {
}
}
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: RecordTypeCNAME,
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 TestIsOwnedBy(t *testing.T) {
type fields struct {
Labels Labels