mirror of https://github.com/kubernetes/kops.git
add unit test for Contains
Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
This commit is contained in:
parent
0ea6d02c54
commit
eff94028dd
|
|
@ -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 = "go_default_library",
|
||||
|
|
@ -6,3 +6,9 @@ go_library(
|
|||
importpath = "k8s.io/kops/util/pkg/slice",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["slice_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -45,3 +45,28 @@ func TestGetUniqueStrings(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestContains(t *testing.T) {
|
||||
tests := []struct {
|
||||
listStr []string
|
||||
e string
|
||||
contains bool
|
||||
}{
|
||||
{
|
||||
listStr: []string{"a", "b"},
|
||||
e: "a",
|
||||
contains: true,
|
||||
},
|
||||
{
|
||||
listStr: []string{"a", "b"},
|
||||
e: "c",
|
||||
contains: false,
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
contains := Contains(test.listStr, test.e)
|
||||
if test.contains != contains {
|
||||
t.Errorf("Expected %v, got %v", test.contains, contains)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue