@@ -308,7 +308,7 @@ func Test_getParentStatusKey(t *testing.T) {
308308 Port : portPtr (80 ),
309309 },
310310 },
311- want : "test-namespace/test-gateway/test-section/80" ,
311+ want : "networking.k8s.io/Gateway/ test-namespace/test-gateway/test-section/80" ,
312312 },
313313 {
314314 name : "no namespace should use route namespace" ,
@@ -321,7 +321,7 @@ func Test_getParentStatusKey(t *testing.T) {
321321 Port : portPtr (80 ),
322322 },
323323 },
324- want : "route-namespace/test-gateway/test-section/80" ,
324+ want : "networking.k8s.io/Gateway/ route-namespace/test-gateway/test-section/80" ,
325325 },
326326 {
327327 name : "no section or port" ,
@@ -333,7 +333,7 @@ func Test_getParentStatusKey(t *testing.T) {
333333 Name : "test-gateway" ,
334334 },
335335 },
336- want : "test-namespace/test-gateway//" ,
336+ want : "networking.k8s.io/Gateway/ test-namespace/test-gateway//" ,
337337 },
338338 }
339339
@@ -353,7 +353,7 @@ func TestEnqueue(t *testing.T) {
353353 routeData routeutils.RouteData
354354 routeStatusInfo routeutils.RouteStatusInfo
355355 routeMetadataDescriptor routeutils.RouteMetadata
356- parentRefGateway routeutils. ParentRefGateway
356+ parentRefGateway gwv1. ParentReference
357357
358358 validateEnqueued func (t * testing.T , enqueued []routeutils.EnqueuedType ) // Use the type here
359359 }{
@@ -369,7 +369,7 @@ func TestEnqueue(t *testing.T) {
369369 RouteNamespace : "test-namespace" ,
370370 RouteKind : "test-kind" ,
371371 },
372- ParentRefGateway : routeutils. ParentRefGateway {},
372+ ParentRef : gwv1. ParentReference {},
373373 },
374374 validateEnqueued : func (t * testing.T , enqueued []routeutils.EnqueuedType ) {
375375 assert .Len (t , enqueued , 1 )
@@ -392,7 +392,7 @@ func TestEnqueue(t *testing.T) {
392392 RouteNamespace : "test-namespace" ,
393393 RouteKind : "test-kind" ,
394394 },
395- ParentRefGateway : routeutils. ParentRefGateway {},
395+ ParentRef : gwv1. ParentReference {},
396396 },
397397 validateEnqueued : func (t * testing.T , enqueued []routeutils.EnqueuedType ) {
398398 assert .Len (t , enqueued , 1 )
@@ -414,7 +414,7 @@ func TestEnqueue(t *testing.T) {
414414 RouteNamespace : "test-namespace" ,
415415 RouteKind : "test-kind" ,
416416 },
417- ParentRefGateway : routeutils. ParentRefGateway {},
417+ ParentRef : gwv1. ParentReference {},
418418 },
419419 validateEnqueued : func (t * testing.T , enqueued []routeutils.EnqueuedType ) {
420420 assert .Len (t , enqueued , 1 )
@@ -439,6 +439,7 @@ func TestEnqueue(t *testing.T) {
439439}
440440
441441func Test_updateRouteStatus (t * testing.T ) {
442+ testNamespace := gwv1 .Namespace ("test-namespace" )
442443 tests := []struct {
443444 name string
444445 route client.Object
@@ -463,9 +464,9 @@ func Test_updateRouteStatus(t *testing.T) {
463464 Reason : string (gwv1 .RouteConditionAccepted ),
464465 Message : "route accepted" ,
465466 },
466- ParentRefGateway : routeutils. ParentRefGateway {
467+ ParentRef : gwv1. ParentReference {
467468 Name : "test-gateway" ,
468- Namespace : "test-namespace" ,
469+ Namespace : & testNamespace ,
469470 },
470471 },
471472 validateResult : func (t * testing.T , route client.Object ) {
@@ -734,52 +735,69 @@ func findCondition(conditions []metav1.Condition, conditionType string) *metav1.
734735}
735736
736737func Test_getParentRefKeyFromRouteData (t * testing.T ) {
738+ testNamespace := gwv1 .Namespace ("test-namespace" )
739+ testGroup := gwv1 .Group ("test-group" )
740+ testKind := gwv1 .Kind ("test-kind" )
741+ routeNamespace := "route-namespace"
737742 tests := []struct {
738743 name string
739- gatewayRef routeutils. ParentRefGateway
744+ gatewayRef gwv1. ParentReference
740745 want string
741746 }{
742747 {
743748 name : "all fields provided" ,
744- gatewayRef : routeutils.ParentRefGateway {
745- Namespace : "test-namespace" ,
749+ gatewayRef : gwv1.ParentReference {
750+ Group : & testGroup ,
751+ Kind : & testKind ,
752+ Namespace : & testNamespace ,
753+ Name : "test-gateway" ,
754+ SectionName : ptr .To (gwv1 .SectionName ("test-section" )),
755+ Port : ptr .To (gwv1 .PortNumber (80 )),
756+ },
757+ want : "test-group/test-kind/test-namespace/test-gateway/test-section/80" ,
758+ },
759+ {
760+ name : "no namespace provided" ,
761+ gatewayRef : gwv1.ParentReference {
762+ Group : & testGroup ,
763+ Kind : & testKind ,
746764 Name : "test-gateway" ,
747765 SectionName : ptr .To (gwv1 .SectionName ("test-section" )),
748766 Port : ptr .To (gwv1 .PortNumber (80 )),
749767 },
750- want : "test-namespace/test-gateway/test-section/80" ,
768+ want : "test-group/test-kind/route- namespace/test-gateway/test-section/80" ,
751769 },
752770 {
753771 name : "no section or port" ,
754- gatewayRef : routeutils. ParentRefGateway {
755- Namespace : "test-namespace" ,
772+ gatewayRef : gwv1. ParentReference {
773+ Namespace : & testNamespace ,
756774 Name : "test-gateway" ,
757775 },
758- want : "test-namespace/test-gateway//" ,
776+ want : "// test-namespace/test-gateway//" ,
759777 },
760778 {
761779 name : "with port only" ,
762- gatewayRef : routeutils. ParentRefGateway {
763- Namespace : "test-namespace" ,
780+ gatewayRef : gwv1. ParentReference {
781+ Namespace : & testNamespace ,
764782 Name : "test-gateway" ,
765783 Port : ptr .To (gwv1 .PortNumber (443 )),
766784 },
767- want : "test-namespace/test-gateway//443" ,
785+ want : "// test-namespace/test-gateway//443" ,
768786 },
769787 {
770788 name : "with section only" ,
771- gatewayRef : routeutils. ParentRefGateway {
772- Namespace : "test-namespace" ,
789+ gatewayRef : gwv1. ParentReference {
790+ Namespace : & testNamespace ,
773791 Name : "test-gateway" ,
774792 SectionName : ptr .To (gwv1 .SectionName ("https" )),
775793 },
776- want : "test-namespace/test-gateway/https/" ,
794+ want : "// test-namespace/test-gateway/https/" ,
777795 },
778796 }
779797
780798 for _ , tt := range tests {
781799 t .Run (tt .name , func (t * testing.T ) {
782- got := getParentRefKeyFromRouteData (tt .gatewayRef )
800+ got := getParentRefKeyFromRouteData (tt .gatewayRef , routeNamespace )
783801 assert .Equal (t , tt .want , got )
784802 })
785803 }
0 commit comments