Skip to content

Commit 92caf12

Browse files
committed
Remove duplicate error checks
1 parent 869a091 commit 92caf12

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

tests/cel/clientsettingspolicy_test.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ func validateClientSettingsPolicy(t *testing.T, tt struct {
130130
t.Helper()
131131
g := NewWithT(t)
132132

133-
k8sClient, err := getKubernetesClient(t)
134-
135-
g.Expect(err).ToNot(HaveOccurred())
136-
137-
g.Expect(err).ToNot(HaveOccurred())
138133
policySpec := tt.policySpec
139134
policySpec.TargetRef.Name = gatewayv1alpha2.ObjectName(uniqueResourceName(testTargetRefName))
140135
policyName := uniqueResourceName(testPolicyName)
@@ -147,6 +142,10 @@ func validateClientSettingsPolicy(t *testing.T, tt struct {
147142
Spec: policySpec,
148143
}
149144

145+
k8sClient, err := getKubernetesClient(t)
146+
147+
g.Expect(err).ToNot(HaveOccurred())
148+
150149
err = k8sClient.Create(context.Background(), clientSettingsPolicy)
151150

152151
// Clean up after test
@@ -159,12 +158,7 @@ func validateClientSettingsPolicy(t *testing.T, tt struct {
159158
} else {
160159
g.Expect(err).To(HaveOccurred())
161160
for _, wantError := range tt.wantErrors {
162-
g.Expect(err.Error()).To(ContainSubstring(wantError))
161+
g.Expect(err.Error()).To(ContainSubstring(wantError), "Expected error '%s' not found in: %s", wantError, err.Error())
163162
}
164163
}
165-
166-
// Check that we got the expected error messages
167-
for _, wantError := range tt.wantErrors {
168-
g.Expect(err.Error()).To(ContainSubstring(wantError), "Expected error '%s' not found in: %s", wantError, err.Error())
169-
}
170164
}

tests/cel/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
. "github.com/onsi/gomega"
77
)
88

9-
func TestMustGenerateRandomPrimeNumer(t *testing.T) {
9+
func TestMustGenerateRandomPrimeNumber(t *testing.T) {
1010
t.Parallel()
1111
g := NewWithT(t)
1212
g.Expect(func() {

0 commit comments

Comments
 (0)