@@ -559,6 +559,14 @@ func TestGetIPFamiliesEnabled(t *testing.T) {
559559 true ,
560560 false ,
561561 },
562+ {
563+ "IPv6" ,
564+ & v1.Service {
565+ Spec : v1.ServiceSpec {IPFamilies : []v1.IPFamily {v1 .IPv6Protocol }},
566+ },
567+ false ,
568+ true ,
569+ },
562570 {
563571 "DualStack" ,
564572 & v1.Service {
@@ -567,6 +575,54 @@ func TestGetIPFamiliesEnabled(t *testing.T) {
567575 true ,
568576 true ,
569577 },
578+ {
579+ "DualStack IPv6 first" ,
580+ & v1.Service {
581+ Spec : v1.ServiceSpec {IPFamilies : []v1.IPFamily {v1 .IPv6Protocol , v1 .IPv4Protocol }},
582+ },
583+ true ,
584+ true ,
585+ },
586+ {
587+ "Empty IPFamilies - defaults to IPv4" ,
588+ & v1.Service {
589+ Spec : v1.ServiceSpec {IPFamilies : []v1.IPFamily {}},
590+ },
591+ true ,
592+ false ,
593+ },
594+ {
595+ "No IPFamilies field - defaults to IPv4" ,
596+ & v1.Service {
597+ Spec : v1.ServiceSpec {},
598+ },
599+ true ,
600+ false ,
601+ },
602+ {
603+ "Multiple IPv4 entries" ,
604+ & v1.Service {
605+ Spec : v1.ServiceSpec {IPFamilies : []v1.IPFamily {v1 .IPv4Protocol , v1 .IPv4Protocol }},
606+ },
607+ true ,
608+ false ,
609+ },
610+ {
611+ "Multiple IPv6 entries" ,
612+ & v1.Service {
613+ Spec : v1.ServiceSpec {IPFamilies : []v1.IPFamily {v1 .IPv6Protocol , v1 .IPv6Protocol }},
614+ },
615+ false ,
616+ true ,
617+ },
618+ {
619+ "Mixed multiple entries" ,
620+ & v1.Service {
621+ Spec : v1.ServiceSpec {IPFamilies : []v1.IPFamily {v1 .IPv4Protocol , v1 .IPv6Protocol , v1 .IPv4Protocol }},
622+ },
623+ true ,
624+ true ,
625+ },
570626 }
571627 for _ , tc := range testcases {
572628 t .Run (tc .desc , func (t * testing.T ) {
0 commit comments