diff --git a/pkg/controller/plan/adapter/vsphere/BUILD.bazel b/pkg/controller/plan/adapter/vsphere/BUILD.bazel index f5e1062ae..380efa315 100644 --- a/pkg/controller/plan/adapter/vsphere/BUILD.bazel +++ b/pkg/controller/plan/adapter/vsphere/BUILD.bazel @@ -60,7 +60,6 @@ go_test( "//pkg/apis/forklift/v1beta1/plan", "//pkg/apis/forklift/v1beta1/ref", "//pkg/controller/plan/context", - "//pkg/controller/plan/util", "//pkg/controller/provider/model/vsphere", "//pkg/controller/provider/web", "//pkg/controller/provider/web/vsphere", diff --git a/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go b/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go index 8e154039b..da4192991 100644 --- a/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go +++ b/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go @@ -3,7 +3,6 @@ package vsphere import ( "testing" - utils "github.com/konveyor/forklift-controller/pkg/controller/plan/util" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -12,28 +11,3 @@ func TestVsphere(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "vSphere Suite") } - -func TestGetDeviceNumber(t *testing.T) { - tests := []struct { - input string - expected int - }{ - {"/dev/sda", 1}, - {"/dev/sdb", 2}, - {"/dev/sdz", 26}, - {"/dev/sda1", 1}, - {"/dev/sda5", 1}, - {"/dev/sdb2", 2}, - {"/dev/sdza", 26}, - {"/dev/sdzb", 26}, - {"/dev/sd", 0}, - {"test", 0}, - } - - for _, test := range tests { - result := utils.GetDeviceNumber(test.input) - if result != test.expected { - t.Errorf("For input '%s', expected %d, but got %d", test.input, test.expected, result) - } - } -} diff --git a/pkg/controller/plan/util/BUILD.bazel b/pkg/controller/plan/util/BUILD.bazel index 54588add3..195f4cb78 100644 --- a/pkg/controller/plan/util/BUILD.bazel +++ b/pkg/controller/plan/util/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "util", @@ -18,3 +18,16 @@ go_library( "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:meta", ], ) + +go_test( + name = "util_test", + srcs = [ + "util_suite_test.go", + "utils_test.go", + ], + embed = [":util"], + deps = [ + "//vendor/github.com/onsi/ginkgo/v2:ginkgo", + "//vendor/github.com/onsi/gomega", + ], +) diff --git a/pkg/controller/plan/util/util_suite_test.go b/pkg/controller/plan/util/util_suite_test.go new file mode 100644 index 000000000..53e985e8a --- /dev/null +++ b/pkg/controller/plan/util/util_suite_test.go @@ -0,0 +1,13 @@ +package util + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestUtil(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "plan/util Suite") +} diff --git a/pkg/controller/plan/util/utils_test.go b/pkg/controller/plan/util/utils_test.go new file mode 100644 index 000000000..3df23310e --- /dev/null +++ b/pkg/controller/plan/util/utils_test.go @@ -0,0 +1,23 @@ +package util + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Plan/utils", func() { + DescribeTable("convert dev", func(dev string, number int) { + Expect(GetDeviceNumber(dev)).Should(Equal(number)) + }, + Entry("sda", "/dev/sda", 1), + Entry("sdb", "/dev/sdb", 2), + Entry("sdz", "/dev/sdz", 26), + Entry("sda1", "/dev/sda1", 1), + Entry("sda5", "/dev/sda5", 1), + Entry("sdb2", "/dev/sdb2", 2), + Entry("sdza", "/dev/sdza", 26), + Entry("sdzb", "/dev/sdzb", 26), + Entry("sd", "/dev/sd", 0), + Entry("test", "test", 0), + ) +})