diff --git a/endpoint/endpoint_test.go b/endpoint/endpoint_test.go index 0d87c2bbe..cd38208e4 100644 --- a/endpoint/endpoint_test.go +++ b/endpoint/endpoint_test.go @@ -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