Skip to content

Commit 5eeed0c

Browse files
committed
fix test readability
1 parent c38b4bf commit 5eeed0c

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

internal/controller/state/graph/policies_test.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,17 +2037,15 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
20372037

20382038
tests := []struct {
20392039
name string
2040-
ctlrName string
20412040
currentAncestors []v1alpha2.PolicyAncestorStatus
20422041
updatedAncestorsLen int
2043-
expected bool
2042+
expectFull bool
20442043
}{
20452044
{
20462045
name: "empty current ancestors, no updated ancestors",
20472046
currentAncestors: []v1alpha2.PolicyAncestorStatus{},
20482047
updatedAncestorsLen: 0,
2049-
ctlrName: "nginx-gateway",
2050-
expected: false,
2048+
expectFull: false,
20512049
},
20522050
{
20532051
name: "less than 16 total (current + updated)",
@@ -2056,8 +2054,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
20562054
getAncestorRef("other-controller", "gateway2"),
20572055
},
20582056
updatedAncestorsLen: 2,
2059-
ctlrName: "nginx-gateway",
2060-
expected: false,
2057+
expectFull: false,
20612058
},
20622059
{
20632060
name: "exactly 16 non-NGF ancestors, no updated ancestors",
@@ -2069,8 +2066,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
20692066
return ancestors
20702067
}(),
20712068
updatedAncestorsLen: 1, // Trying to add 1 NGF ancestor
2072-
ctlrName: "nginx-gateway",
2073-
expected: true,
2069+
expectFull: true,
20742070
},
20752071
{
20762072
name: "15 non-NGF + 1 NGF ancestor, adding 1 more NGF ancestor",
@@ -2083,8 +2079,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
20832079
return ancestors
20842080
}(),
20852081
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
20882083
},
20892084
{
20902085
name: "10 non-NGF ancestors, trying to add 7 NGF ancestors (would exceed 16)",
@@ -2096,8 +2091,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
20962091
return ancestors
20972092
}(),
20982093
updatedAncestorsLen: 7,
2099-
ctlrName: "nginx-gateway",
2100-
expected: true,
2094+
expectFull: true,
21012095
},
21022096
{
21032097
name: "5 non-NGF + 5 NGF ancestors, trying to add 6 more NGF ancestors",
@@ -2112,8 +2106,7 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
21122106
return ancestors
21132107
}(),
21142108
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)
21172110
},
21182111
}
21192112

@@ -2131,8 +2124,8 @@ func TestNGFPolicyAncestorsFullFunc(t *testing.T) {
21312124
})
21322125
}
21332126

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))
21362129
})
21372130
}
21382131
}
@@ -2146,7 +2139,7 @@ func TestNGFPolicyAncestorLimitHandling(t *testing.T) {
21462139

21472140
policyGVK := schema.GroupVersionKind{Group: "Group", Version: "Version", Kind: "TestPolicy"}
21482141

2149-
// Create a policy with 16 non-NGF ancestors (ancestor limit reached)
2142+
// Helper function to create ancestor references
21502143
getAncestorRef := func(ctlrName, parentName string) v1alpha2.PolicyAncestorStatus {
21512144
return v1alpha2.PolicyAncestorStatus{
21522145
ControllerName: v1.GatewayController(ctlrName),

0 commit comments

Comments
 (0)