@@ -271,10 +271,6 @@ func TestGetServiceAndPortFromRef(t *testing.T) {
271271 IPFamilies : []v1.IPFamily {v1 .IPv4Protocol },
272272 },
273273 }
274- svc1NsName := types.NamespacedName {
275- Namespace : "test" ,
276- Name : "service1" ,
277- }
278274
279275 svc2 := & v1.Service {
280276 ObjectMeta : metav1.ObjectMeta {
@@ -284,49 +280,48 @@ func TestGetServiceAndPortFromRef(t *testing.T) {
284280 }
285281
286282 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
293289 }{
294290 {
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 },
300295 },
301296 {
302297 name : "service does not exist" ,
303298 ref : getModifiedRef (func (backend gatewayv1.BackendRef ) gatewayv1.BackendRef {
304299 backend .Name = "does-not-exist"
305300 return backend
306301 }),
307- expErr : true ,
308- expServiceNsName : types.NamespacedName {Name : "does-not-exist" , Namespace : "test" },
309- expServicePort : v1.ServicePort {},
302+ expErr : true ,
303+ expServicePort : v1.ServicePort {},
310304 expSvc : & v1.Service {
311305 ObjectMeta : metav1.ObjectMeta {
312306 Name : "does-not-exist" , Namespace : "test" ,
313307 },
314308 },
309+ expSvcIPFamily : []v1.IPFamily {},
315310 },
316311 {
317312 name : "no matching port for service and port" ,
318313 ref : getModifiedRef (func (backend gatewayv1.BackendRef ) gatewayv1.BackendRef {
319314 backend .Port = helpers.GetPointer [gatewayv1.PortNumber ](504 )
320315 return backend
321316 }),
322- expErr : true ,
323- expServiceNsName : svc1NsName ,
324- expServicePort : v1.ServicePort {},
317+ expErr : true ,
318+ expServicePort : v1.ServicePort {},
325319 expSvc : & v1.Service {
326320 ObjectMeta : metav1.ObjectMeta {
327321 Name : "service1" , Namespace : "test" ,
328322 },
329323 },
324+ expSvcIPFamily : []v1.IPFamily {},
330325 },
331326 }
332327
@@ -341,11 +336,11 @@ func TestGetServiceAndPortFromRef(t *testing.T) {
341336 t .Run (test .name , func (t * testing.T ) {
342337 g := NewWithT (t )
343338
344- svc , servicePort , err := getServiceAndPortFromRef (test .ref , "test" , services , refPath )
339+ svcIPFamily , servicePort , err := getServiceAndPortFromRef (test .ref , "test" , services , refPath )
345340
346341 g .Expect (err != nil ).To (Equal (test .expErr ))
347342 g .Expect (servicePort ).To (Equal (test .expServicePort ))
348- g .Expect (svc ).To (Equal (test .expSvc ))
343+ g .Expect (svcIPFamily ).To (Equal (test .expSvcIPFamily ))
349344 })
350345 }
351346}
@@ -953,6 +948,10 @@ func TestCreateBackend(t *testing.T) {
953948 expectedBackend : BackendRef {
954949 Weight : 5 ,
955950 Valid : false ,
951+ SvcNsName : types.NamespacedName {
952+ Namespace : "test" ,
953+ Name : "not-exist" ,
954+ },
956955 },
957956 expectedServicePortReference : "" ,
958957 expectedCondition : helpers .GetPointer (
0 commit comments