@@ -2037,17 +2037,15 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2037
2037
2038
2038
tests := []struct {
2039
2039
name string
2040
- ctlrName string
2041
2040
currentAncestors []v1alpha2.PolicyAncestorStatus
2042
2041
updatedAncestorsLen int
2043
- expected bool
2042
+ expectFull bool
2044
2043
}{
2045
2044
{
2046
2045
name : "empty current ancestors, no updated ancestors" ,
2047
2046
currentAncestors : []v1alpha2.PolicyAncestorStatus {},
2048
2047
updatedAncestorsLen : 0 ,
2049
- ctlrName : "nginx-gateway" ,
2050
- expected : false ,
2048
+ expectFull : false ,
2051
2049
},
2052
2050
{
2053
2051
name : "less than 16 total (current + updated)" ,
@@ -2056,8 +2054,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2056
2054
getAncestorRef ("other-controller" , "gateway2" ),
2057
2055
},
2058
2056
updatedAncestorsLen : 2 ,
2059
- ctlrName : "nginx-gateway" ,
2060
- expected : false ,
2057
+ expectFull : false ,
2061
2058
},
2062
2059
{
2063
2060
name : "exactly 16 non-NGF ancestors, no updated ancestors" ,
@@ -2069,8 +2066,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2069
2066
return ancestors
2070
2067
}(),
2071
2068
updatedAncestorsLen : 1 , // Trying to add 1 NGF ancestor
2072
- ctlrName : "nginx-gateway" ,
2073
- expected : true ,
2069
+ expectFull : true ,
2074
2070
},
2075
2071
{
2076
2072
name : "15 non-NGF + 1 NGF ancestor, adding 1 more NGF ancestor" ,
@@ -2083,8 +2079,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2083
2079
return ancestors
2084
2080
}(),
2085
2081
updatedAncestorsLen : 1 ,
2086
- ctlrName : "nginx-gateway" ,
2087
- expected : true , // Full because 15 non-NGF + 1 new NGF = 16 which is the limit
2082
+ expectFull : true , // Full because 15 non-NGF + 1 new NGF = 16 which is the limit
2088
2083
},
2089
2084
{
2090
2085
name : "10 non-NGF ancestors, trying to add 7 NGF ancestors (would exceed 16)" ,
@@ -2096,8 +2091,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2096
2091
return ancestors
2097
2092
}(),
2098
2093
updatedAncestorsLen : 7 ,
2099
- ctlrName : "nginx-gateway" ,
2100
- expected : true ,
2094
+ expectFull : true ,
2101
2095
},
2102
2096
{
2103
2097
name : "5 non-NGF + 5 NGF ancestors, trying to add 6 more NGF ancestors" ,
@@ -2112,8 +2106,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2112
2106
return ancestors
2113
2107
}(),
2114
2108
updatedAncestorsLen : 6 ,
2115
- ctlrName : "nginx-gateway" ,
2116
- expected : false , // 5 non-NGF + 6 new NGF = 11 total (within limit)
2109
+ expectFull : false , // 5 non-NGF + 6 new NGF = 11 total (within limit)
2117
2110
},
2118
2111
}
2119
2112
@@ -2131,8 +2124,8 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
2131
2124
})
2132
2125
}
2133
2126
2134
- result := ngfPolicyAncestorsFull (policy , test . ctlrName )
2135
- g .Expect (result ).To (Equal (test .expected ))
2127
+ result := ngfPolicyAncestorsFull (policy , "nginx-gateway" )
2128
+ g .Expect (result ).To (Equal (test .expectFull ))
2136
2129
})
2137
2130
}
2138
2131
}
@@ -2146,7 +2139,7 @@ func TestNGFPolicyAncestorLimitHandling(t *testing.T) {
2146
2139
2147
2140
policyGVK := schema.GroupVersionKind {Group : "Group" , Version : "Version" , Kind : "TestPolicy" }
2148
2141
2149
- // Create a policy with 16 non-NGF ancestors ( ancestor limit reached)
2142
+ // Helper function to create ancestor references
2150
2143
getAncestorRef := func (ctlrName , parentName string ) v1alpha2.PolicyAncestorStatus {
2151
2144
return v1alpha2.PolicyAncestorStatus {
2152
2145
ControllerName : v1 .GatewayController (ctlrName ),
0 commit comments