@@ -622,6 +622,7 @@ func TestStackGenerateRouteGroup(t *testing.T) {
622622 expectedAnnotations map [string ]string
623623 expectedHosts []string
624624 expectedBackend []rgv1.RouteGroupBackend
625+ expectedRouteGroup * rgv1.RouteGroup
625626 }{
626627 {
627628 name : "no route group spec" ,
@@ -691,6 +692,53 @@ func TestStackGenerateRouteGroup(t *testing.T) {
691692 Type : rgv1 .ForwardRouteGroupBackend ,
692693 },
693694 },
695+ expectedRouteGroup : & rgv1.RouteGroup {
696+ ObjectMeta : metav1.ObjectMeta {
697+ Name : "foo-v1" ,
698+ Namespace : "bar" ,
699+ Annotations : map [string ]string {
700+ stackGenerationAnnotationKey : "11" ,
701+ "routegroup" : "annotation" ,
702+ },
703+ Labels : map [string ]string {
704+ StacksetHeritageLabelKey : "foo" ,
705+ StackVersionLabelKey : "v1" ,
706+ "stack-label" : "foobar" ,
707+ },
708+ OwnerReferences : []metav1.OwnerReference {
709+ {
710+ APIVersion : APIVersion ,
711+ Kind : KindStack ,
712+ Name : "foo-v1" ,
713+ UID : "abc-123" ,
714+ },
715+ },
716+ },
717+ Spec : rgv1.RouteGroupSpec {
718+ Hosts : []string {"foo-v1.example.org" },
719+ Backends : []rgv1.RouteGroupBackend {
720+ {
721+ Name : "fwd" ,
722+ Type : rgv1 .ForwardRouteGroupBackend ,
723+ },
724+ },
725+ DefaultBackends : []rgv1.RouteGroupBackendReference {
726+ {
727+ BackendName : "fwd" ,
728+ },
729+ },
730+ Routes : []rgv1.RouteGroupRouteSpec {
731+ {
732+ Backends : []rgv1.RouteGroupBackendReference {
733+ {
734+ BackendName : "fwd" ,
735+ },
736+ },
737+ PathSubtree : "/example" ,
738+ },
739+ },
740+ },
741+ },
694742 },
695743 } {
696744 t .Run (tc .name , func (t * testing.T ) {
@@ -754,21 +802,25 @@ func TestStackGenerateRouteGroup(t *testing.T) {
754802 },
755803 },
756804 }
757- if tc .expectedBackend != nil {
758- expected .Spec .Backends = tc .expectedBackend
759- }
760- for _ , be := range tc .expectedBackend {
761- found := false
762- for _ , specBE := range rg .Spec .Backends {
763- if be .Type == specBE .Type {
764- found = true
765- break
766- }
767- }
768- if ! found {
769- t .Fatalf ("Failed to find backend %v, got %v" , be , rg .Spec .Backends )
770- }
805+
806+ if tc .expectedRouteGroup != nil {
807+ expected = tc .expectedRouteGroup
771808 }
809+ // if tc.expectedBackend != nil {
810+ // expected.Spec.Backends = tc.expectedBackend
811+ // }
812+ // for _, be := range tc.expectedBackend {
813+ // found := false
814+ // for _, specBE := range rg.Spec.Backends {
815+ // if be.Type == specBE.Type {
816+ // found = true
817+ // break
818+ // }
819+ // }
820+ // if !found {
821+ // t.Fatalf("Failed to find backend %v, got %v", be, rg.Spec.Backends)
822+ // }
823+ // }
772824 require .Equal (t , expected , rg )
773825 })
774826 }
0 commit comments