Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 29 additions & 0 deletions pkg/common/common_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2022 The Fluid Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package common

import (
"testing"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)

func TestCommon(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Package Common Suite")
}
31 changes: 13 additions & 18 deletions pkg/common/critical_fuse_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,18 @@ limitations under the License.
package common

import (
"testing"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)

func TestCriticalFusePodEnabled(t *testing.T) {
want := false
got := CriticalFusePodEnabled()

if got != want {
t.Errorf("want %v, got %v", want, got)
}
}

func TestPortCheckEnabled(t *testing.T) {
want := false
got := PortCheckEnabled()

if got != want {
t.Errorf("want %v, got %v", want, got)
}
}
var _ = ginkgo.Describe("CriticalFusePodEnabled", func() {
ginkgo.It("should return false by default", func() {
gomega.Expect(CriticalFusePodEnabled()).To(gomega.BeFalse())
})
})

var _ = ginkgo.Describe("PortCheckEnabled", func() {
ginkgo.It("should return false by default", func() {
gomega.Expect(PortCheckEnabled()).To(gomega.BeFalse())
})
})
Comment on lines +24 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For test cases that follow the same pattern, you can use ginkgo.DescribeTable to make the tests more concise and maintainable. This avoids duplicating the test logic for each function.

var _ = ginkgo.DescribeTable("Default boolean flags",
	func(f func() bool) {
		gomega.Expect(f()).To(gomega.BeFalse())
	},
	ginkgo.Entry("CriticalFusePodEnabled should be false by default", CriticalFusePodEnabled),
	ginkgo.Entry("PortCheckEnabled should be false by default", PortCheckEnabled),
)