Skip to content

Replace unit test assertions with Gomega matchers #1046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace t.Fatal instances with Gomega assertions
  • Loading branch information
bjee19 committed Sep 11, 2023
commit 00b99364621029ab7a09c26f1622a7f547210d6e
7 changes: 2 additions & 5 deletions internal/framework/controller/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
func TestCreateSingleResourceFilter(t *testing.T) {
targetNsName := types.NamespacedName{Namespace: "test", Name: "resource"}

g := NewGomegaWithT(t)
filter := CreateSingleResourceFilter(targetNsName)
if filter == nil {
t.Fatal("TestCreateSingleResourceFilter() returned nil filter")
}
g.Expect(filter).ToNot(BeNil())

const expectedMsg = "Resource is ignored because this controller only supports a single resource " +
"test/resource of that type"
Expand Down Expand Up @@ -52,8 +51,6 @@ func TestCreateSingleResourceFilter(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
g := NewGomegaWithT(t)

shouldProcess, msg := filter(test.nsname)
g.Expect(shouldProcess).To(Equal(test.expectedShouldProcess))
g.Expect(msg).To(Equal(test.expectedMsg))
Expand Down
5 changes: 2 additions & 3 deletions internal/mode/static/nginx/file/folders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import (

func writeFile(t *testing.T, name string, data []byte) {
t.Helper()
g := NewGomegaWithT(t)

//nolint:gosec // the file permission is ok for unit testing
if err := os.WriteFile(name, data, 0o644); err != nil {
t.Fatal(err)
}
g.Expect(os.WriteFile(name, data, 0o644)).Should(Succeed())
}

func TestClearFoldersRemoves(t *testing.T) {
Expand Down