Skip to content

Commit

Permalink
chore: address review's suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Grzegorz Burzyński <[email protected]>
Signed-off-by: Mattia Lavacca <[email protected]>
  • Loading branch information
mlavacca and czeslavo committed Dec 14, 2023
1 parent 4c0520b commit e972c1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Adding a new version? You'll need three changes:
- using filters in backendRefs of rules
[#5312](https://github.com/Kong/kubernetes-ingress-controller/pull/5312)
- Added functionality to the `KongUpstreamPolicy` controller to properly set and
enforce `KongUpstreamPolicy`status.
enforce `KongUpstreamPolicy` status.
[#5185](https://github.com/Kong/kubernetes-ingress-controller/pull/5185)

### Fixed
Expand Down
28 changes: 14 additions & 14 deletions internal/controllers/configuration/kongupstreampolicy_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {

testCases := []struct {
name string
kongupstreamPolicy kongv1beta1.KongUpstreamPolicy
kongUpstreamPolicy kongv1beta1.KongUpstreamPolicy
inputObjects []client.Object
expectedkongUpstreamPolicyStatus gatewayapi.PolicyStatus
expectedKongUpstreamPolicyStatus gatewayapi.PolicyStatus
updated bool
}{
{
name: "2 services referencing the same policy, all accepted. Status update.",
kongupstreamPolicy: kongv1beta1.KongUpstreamPolicy{
kongUpstreamPolicy: kongv1beta1.KongUpstreamPolicy{
ObjectMeta: metav1.ObjectMeta{
Name: policyName,
Namespace: testNamespace,
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
},
},
},
expectedkongUpstreamPolicyStatus: gatewayapi.PolicyStatus{
expectedKongUpstreamPolicyStatus: gatewayapi.PolicyStatus{
Ancestors: []gatewayapi.PolicyAncestorStatus{
{
AncestorRef: gatewayapi.ParentReference{
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
},
{
name: "2 services referencing the same policy, all accepted. No status update.",
kongupstreamPolicy: kongv1beta1.KongUpstreamPolicy{
kongUpstreamPolicy: kongv1beta1.KongUpstreamPolicy{
ObjectMeta: metav1.ObjectMeta{
Name: policyName,
Namespace: testNamespace,
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
},
},
},
expectedkongUpstreamPolicyStatus: gatewayapi.PolicyStatus{
expectedKongUpstreamPolicyStatus: gatewayapi.PolicyStatus{
Ancestors: []gatewayapi.PolicyAncestorStatus{
{
AncestorRef: gatewayapi.ParentReference{
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
},
{
name: "2 services referencing different policies, policy with conflict",
kongupstreamPolicy: kongv1beta1.KongUpstreamPolicy{
kongUpstreamPolicy: kongv1beta1.KongUpstreamPolicy{
ObjectMeta: metav1.ObjectMeta{
Name: policyName,
Namespace: testNamespace,
Expand Down Expand Up @@ -326,7 +326,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
},
},
},
expectedkongUpstreamPolicyStatus: gatewayapi.PolicyStatus{
expectedKongUpstreamPolicyStatus: gatewayapi.PolicyStatus{
Ancestors: []gatewayapi.PolicyAncestorStatus{
{
AncestorRef: gatewayapi.ParentReference{
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
objectsToAdd := append(tc.inputObjects, &tc.kongupstreamPolicy)
objectsToAdd := append(tc.inputObjects, &tc.kongUpstreamPolicy)
fakeClient := fakectrlruntimeclient.
NewClientBuilder().
WithScheme(scheme.Scheme).
Expand All @@ -370,17 +370,17 @@ func TestEnforceKongUpstreamPolicyStatus(t *testing.T) {
Client: fakeClient,
}

updated, err := reconciler.enforceKongUpstreamPolicyStatus(context.TODO(), &tc.kongupstreamPolicy)
updated, err := reconciler.enforceKongUpstreamPolicyStatus(context.TODO(), &tc.kongUpstreamPolicy)
assert.NoError(t, err)
assert.Equal(t, tc.updated, updated)
newPolicy := &kongv1beta1.KongUpstreamPolicy{}
assert.NoError(t, fakeClient.Get(context.TODO(), k8stypes.NamespacedName{
Namespace: tc.kongupstreamPolicy.Namespace,
Name: tc.kongupstreamPolicy.Name,
Namespace: tc.kongUpstreamPolicy.Namespace,
Name: tc.kongUpstreamPolicy.Name,
}, newPolicy))
assert.Len(t, newPolicy.Status.Ancestors, len(tc.expectedkongUpstreamPolicyStatus.Ancestors))
assert.Len(t, newPolicy.Status.Ancestors, len(tc.expectedKongUpstreamPolicyStatus.Ancestors))
for i, got := range newPolicy.Status.Ancestors {
expected := tc.expectedkongUpstreamPolicyStatus.Ancestors[i]
expected := tc.expectedKongUpstreamPolicyStatus.Ancestors[i]
assert.Equal(t, expected.ControllerName, got.ControllerName)
assert.Equal(t, expected.AncestorRef, got.AncestorRef)
assert.Len(t, got.Conditions, len(expected.Conditions))
Expand Down

0 comments on commit e972c1e

Please sign in to comment.