MCPcopy Create free account
hub / github.com/algolia/cli / TestContains

Function TestContains

pkg/utils/utils_test.go:49–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestContains(t *testing.T) {
50 tests := []struct {
51 name string
52 inputSlice []string
53 stringToTest string
54 expected bool
55 }{
56 {
57 name: "contains in slice",
58 inputSlice: []string{"maguro", "otoro", "unagi"},
59 stringToTest: "otoro",
60 expected: true,
61 },
62 {
63 name: "contains in 1 element slice",
64 inputSlice: []string{"unagi"},
65 stringToTest: "unagi",
66 expected: true,
67 },
68 {
69 name: "empty slice",
70 inputSlice: []string{},
71 stringToTest: "otoro",
72 expected: false,
73 },
74 {
75 name: "missing in slice",
76 inputSlice: []string{"maguro", "otoro", "unagi"},
77 stringToTest: "tamago",
78 expected: false,
79 },
80 }
81
82 for _, tt := range tests {
83 t.Run(tt.name, func(t *testing.T) {
84 assert.Equal(t, tt.expected, Contains(tt.inputSlice, tt.stringToTest))
85 })
86 }
87}
88
89func TestToKebabCase(t *testing.T) {
90 tests := []struct {

Callers

nothing calls this directly

Calls 2

ContainsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected