From cb2c5392803fa96b4bd9b98247c5a3055b2df64e Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Wed, 19 Jun 2024 19:40:53 +0300 Subject: [PATCH] move the test of GetDeviceNumber to the right package Signed-off-by: Arik Hadas --- .../adapter/vsphere/vsphere_suite_test.go | 24 ------------------- pkg/controller/plan/util/util_suite_test.go | 13 ++++++++++ pkg/controller/plan/util/utils_test.go | 23 ++++++++++++++++++ 3 files changed, 36 insertions(+), 24 deletions(-) create mode 100644 pkg/controller/plan/util/util_suite_test.go create mode 100644 pkg/controller/plan/util/utils_test.go diff --git a/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go b/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go index 8e154039b..96b251a7b 100644 --- a/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go +++ b/pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go @@ -13,27 +13,3 @@ func TestVsphere(t *testing.T) { 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/util_suite_test.go b/pkg/controller/plan/util/util_suite_test.go new file mode 100644 index 000000000..69c06b071 --- /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 TestVsphere(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), + ) +})