@@ -271,10 +271,6 @@ func TestGetServiceAndPortFromRef(t *testing.T) {
271
271
IPFamilies : []v1.IPFamily {v1 .IPv4Protocol },
272
272
},
273
273
}
274
- svc1NsName := types.NamespacedName {
275
- Namespace : "test" ,
276
- Name : "service1" ,
277
- }
278
274
279
275
svc2 := & v1.Service {
280
276
ObjectMeta : metav1.ObjectMeta {
@@ -284,49 +280,48 @@ func TestGetServiceAndPortFromRef(t *testing.T) {
284
280
}
285
281
286
282
tests := []struct {
287
- expSvc * v1.Service
288
- ref gatewayv1.BackendRef
289
- expServiceNsName types. NamespacedName
290
- name string
291
- expServicePort v1.ServicePort
292
- expErr bool
283
+ expSvc * v1.Service
284
+ ref gatewayv1.BackendRef
285
+ expSvcIPFamily []v1. IPFamily
286
+ name string
287
+ expServicePort v1.ServicePort
288
+ expErr bool
293
289
}{
294
290
{
295
- name : "normal case" ,
296
- ref : getNormalRef (),
297
- expServiceNsName : svc1NsName ,
298
- expServicePort : v1.ServicePort {Port : 80 },
299
- expSvc : svc1 ,
291
+ name : "normal case" ,
292
+ ref : getNormalRef (),
293
+ expServicePort : v1.ServicePort {Port : 80 },
294
+ expSvcIPFamily : []v1.IPFamily {v1 .IPv4Protocol },
300
295
},
301
296
{
302
297
name : "service does not exist" ,
303
298
ref : getModifiedRef (func (backend gatewayv1.BackendRef ) gatewayv1.BackendRef {
304
299
backend .Name = "does-not-exist"
305
300
return backend
306
301
}),
307
- expErr : true ,
308
- expServiceNsName : types.NamespacedName {Name : "does-not-exist" , Namespace : "test" },
309
- expServicePort : v1.ServicePort {},
302
+ expErr : true ,
303
+ expServicePort : v1.ServicePort {},
310
304
expSvc : & v1.Service {
311
305
ObjectMeta : metav1.ObjectMeta {
312
306
Name : "does-not-exist" , Namespace : "test" ,
313
307
},
314
308
},
309
+ expSvcIPFamily : []v1.IPFamily {},
315
310
},
316
311
{
317
312
name : "no matching port for service and port" ,
318
313
ref : getModifiedRef (func (backend gatewayv1.BackendRef ) gatewayv1.BackendRef {
319
314
backend .Port = helpers.GetPointer [gatewayv1.PortNumber ](504 )
320
315
return backend
321
316
}),
322
- expErr : true ,
323
- expServiceNsName : svc1NsName ,
324
- expServicePort : v1.ServicePort {},
317
+ expErr : true ,
318
+ expServicePort : v1.ServicePort {},
325
319
expSvc : & v1.Service {
326
320
ObjectMeta : metav1.ObjectMeta {
327
321
Name : "service1" , Namespace : "test" ,
328
322
},
329
323
},
324
+ expSvcIPFamily : []v1.IPFamily {},
330
325
},
331
326
}
332
327
@@ -341,11 +336,11 @@ func TestGetServiceAndPortFromRef(t *testing.T) {
341
336
t .Run (test .name , func (t * testing.T ) {
342
337
g := NewWithT (t )
343
338
344
- svc , servicePort , err := getServiceAndPortFromRef (test .ref , "test" , services , refPath )
339
+ svcIPFamily , servicePort , err := getServiceAndPortFromRef (test .ref , "test" , services , refPath )
345
340
346
341
g .Expect (err != nil ).To (Equal (test .expErr ))
347
342
g .Expect (servicePort ).To (Equal (test .expServicePort ))
348
- g .Expect (svc ).To (Equal (test .expSvc ))
343
+ g .Expect (svcIPFamily ).To (Equal (test .expSvcIPFamily ))
349
344
})
350
345
}
351
346
}
@@ -953,6 +948,10 @@ func TestCreateBackend(t *testing.T) {
953
948
expectedBackend : BackendRef {
954
949
Weight : 5 ,
955
950
Valid : false ,
951
+ SvcNsName : types.NamespacedName {
952
+ Namespace : "test" ,
953
+ Name : "not-exist" ,
954
+ },
956
955
},
957
956
expectedServicePortReference : "" ,
958
957
expectedCondition : helpers .GetPointer (
0 commit comments