Skip to content

Commit 08e9177

Browse files
bugfix: add clarification to endpoint unit tests
1 parent 93b831d commit 08e9177

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

endpoint/endpoint_test.go

+58-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestIsLess(t *testing.T) {
153153
}
154154
}
155155

156-
func TestFilterEndpointsByOwnerID(t *testing.T) {
156+
func TestFilterEndpointsByOwnerIDWithRecordTypeA(t *testing.T) {
157157
foo1 := &Endpoint{
158158
DNSName: "foo.com",
159159
RecordType: RecordTypeA,
@@ -162,15 +162,71 @@ func TestFilterEndpointsByOwnerID(t *testing.T) {
162162
},
163163
}
164164
foo2 := &Endpoint{
165+
DNSName: "foo2.com",
166+
RecordType: RecordTypeA,
167+
Labels: Labels{
168+
OwnerLabelKey: "foo",
169+
},
170+
}
171+
bar := &Endpoint{
172+
DNSName: "foo.com",
173+
RecordType: RecordTypeA,
174+
Labels: Labels{
175+
OwnerLabelKey: "bar",
176+
},
177+
}
178+
type args struct {
179+
ownerID string
180+
eps []*Endpoint
181+
}
182+
tests := []struct {
183+
name string
184+
args args
185+
want []*Endpoint
186+
}{
187+
{
188+
name: "filter values",
189+
args: args{
190+
ownerID: "foo",
191+
eps: []*Endpoint{
192+
foo1,
193+
foo2,
194+
bar,
195+
},
196+
},
197+
want: []*Endpoint{
198+
foo1,
199+
foo2,
200+
},
201+
},
202+
}
203+
for _, tt := range tests {
204+
t.Run(tt.name, func(t *testing.T) {
205+
if got := FilterEndpointsByOwnerID(tt.args.ownerID, tt.args.eps); !reflect.DeepEqual(got, tt.want) {
206+
t.Errorf("ApplyEndpointFilter() = %v, want %v", got, tt.want)
207+
}
208+
})
209+
}
210+
}
211+
212+
func TestFilterEndpointsByOwnerIDWithRecordTypeCNAME(t *testing.T) {
213+
foo1 := &Endpoint{
165214
DNSName: "foo.com",
166215
RecordType: RecordTypeCNAME,
167216
Labels: Labels{
168217
OwnerLabelKey: "foo",
169218
},
170219
}
220+
foo2 := &Endpoint{
221+
DNSName: "foo2.com",
222+
RecordType: RecordTypeCNAME,
223+
Labels: Labels{
224+
OwnerLabelKey: "foo",
225+
},
226+
}
171227
bar := &Endpoint{
172228
DNSName: "foo.com",
173-
RecordType: RecordTypeA,
229+
RecordType: RecordTypeCNAME,
174230
Labels: Labels{
175231
OwnerLabelKey: "bar",
176232
},

0 commit comments

Comments
 (0)