mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
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>
44 lines
714 B
Go
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))
|
|
})
|
|
}
|
|
}
|