parent
fa27e41087
commit
3130c9fce0
|
@ -43,3 +43,36 @@ func TestIsAddonValid(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestContains(t *testing.T) {
|
||||
tests := []struct {
|
||||
slice []string
|
||||
str string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
slice: []string{},
|
||||
str: "test",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
slice: []string{"test", "test1"},
|
||||
str: "test1",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
slice: []string{"test", "test1"},
|
||||
str: "test2",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.str, func(t *testing.T) {
|
||||
actual := contains(test.slice, test.str)
|
||||
if test.expected != actual {
|
||||
t.Fatalf("slice: %v\nstr: %v\nexpected: %v\nactual:%v\n", test.slice, test.str, test.expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue