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 2021 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")
}
42 changes: 12 additions & 30 deletions pkg/common/constants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,18 @@ limitations under the License.
package common

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

func TestGetDefaultTieredStoreOrder(t *testing.T) {
testCases := map[string]struct {
mediumType MediumType
want int
}{
"test case 1": {
mediumType: Memory,
want: 0,
var _ = ginkgo.Describe("GetDefaultTieredStoreOrder", func() {
ginkgo.DescribeTable("should return correct order for medium types",
func(mediumType MediumType, expectedOrder int) {
gomega.Expect(GetDefaultTieredStoreOrder(mediumType)).To(gomega.Equal(expectedOrder))
},
"test case 2": {
mediumType: SSD,
want: 1,
},
"test case 3": {
mediumType: HDD,
want: 2,
},
"test case 4": {
mediumType: "unknown",
want: 0,
},
}
for k, item := range testCases {
result := GetDefaultTieredStoreOrder(item.mediumType)
if item.want != result {
t.Errorf("%s cannot paas, want %v, get %v", k, item.want, result)
}
}

}
ginkgo.Entry("Memory returns 0", Memory, 0),
ginkgo.Entry("SSD returns 1", SSD, 1),
ginkgo.Entry("HDD returns 2", HDD, 2),
ginkgo.Entry("unknown returns 0", MediumType("unknown"), 0),
)
})