Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/util/string_test.go

39 lines
777 B

package util
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStringSliceContains(t *testing.T) {
t.Parallel()
tests := map[string]struct {
inputSlice []string
inputValue string
expected bool
}{
"should return false on missing value in the slice": {
inputSlice: []string{"one", "two"},
inputValue: "three",
expected: false,
},
"should return true on existing value in the slice": {
inputSlice: []string{"one", "two"},
inputValue: "two",
expected: true,
},
}
for testName, testData := range tests {
testData := testData
t.Run(testName, func(t *testing.T) {
t.Parallel()
actual := StringSliceContains(testData.inputSlice, testData.inputValue)
assert.Equal(t, testData.expected, actual)
})
}
}