Merge pull request #9533 from Hellcatlk/UnitTest

Add unit test
pull/9531/head
priyawadhwa 2020-10-28 10:25:50 -07:00 committed by GitHub
commit 2fb9f8ebfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -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)
}
})
}
}