Files
kubescape/core/cautils/getter/utils_test.go
VaibhavMalik4187 beb6d9535c Added tests for cautils
Wrote new tests for the following files:
- controllink.go
- display.go
- fileutils.go
- getter/getpoliciesutils.go
- getter/utils.go

Signed-off-by: VaibhavMalik4187 <vaibhavmalik2018@gmail.com>
2023-11-22 20:24:16 +05:30

44 lines
714 B
Go

package getter
import (
"testing"
"github.com/stretchr/testify/assert"
)
// should return true if the string is present in the slice
func TestContains(t *testing.T) {
tests := []struct {
str []string
key string
want bool
}{
{
str: []string{"apple", "banana", "orange"},
key: "banana",
want: true,
},
{
str: []string{"apple", "banana", "orange"},
key: "mango",
want: false,
},
{
str: []string{"", "banana", "banana"},
key: "banana",
want: true,
},
{
str: []string{"", "", ""},
key: "grape",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.key, func(t *testing.T) {
assert.Equal(t, tt.want, contains(tt.str, tt.key))
})
}
}