Skip to content

Commit 29f26ef

Browse files
committed
Update test to use gomega test library
1 parent aa5adc6 commit 29f26ef

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

tests/cel/clientsettingspolicy_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package cel
33
import (
44
"context"
55
"fmt"
6-
"strings"
76
"testing"
87
"time"
98

9+
. "github.com/onsi/gomega"
1010
"k8s.io/apimachinery/pkg/runtime"
1111
controllerruntime "sigs.k8s.io/controller-runtime"
1212
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -188,16 +188,10 @@ func validateClientSettingsPolicy(t *testing.T, tt struct {
188188
t.Errorf("expected validation error but policy was accepted")
189189
return
190190
}
191-
191+
g := NewWithT(t)
192192
// Check that we got the expected error messages
193-
var missingErrors []string
194193
for _, wantError := range tt.wantErrors {
195-
if !strings.Contains(err.Error(), wantError) {
196-
missingErrors = append(missingErrors, wantError)
197-
}
198-
}
199-
if len(missingErrors) != 0 {
200-
t.Errorf("missing expected errors: %v, got: %v", missingErrors, err)
194+
g.Expect(err.Error()).To(ContainSubstring(wantError), "Expected error '%s' not found in: %s", wantError, err.Error())
201195
}
202196
}
203197

0 commit comments

Comments
 (0)