Skip to content

Commit

Permalink
move the test of GetDeviceNumber to the right package
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Jun 19, 2024
1 parent 4bbf97d commit cb2c539
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
24 changes: 0 additions & 24 deletions pkg/controller/plan/adapter/vsphere/vsphere_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
13 changes: 13 additions & 0 deletions pkg/controller/plan/util/util_suite_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
23 changes: 23 additions & 0 deletions pkg/controller/plan/util/utils_test.go
Original file line number Diff line number Diff line change
@@ -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),
)
})

0 comments on commit cb2c539

Please sign in to comment.