MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestStringSlice

Function TestStringSlice

env/types_test.go:240–262  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

238}
239
240func TestStringSlice(t *testing.T) {
241 tests := []struct {
242 input string
243 want []string
244 }{
245 {input: "one,two,three", want: []string{"one", "two", "three"}},
246 {input: " one , two , three ", want: []string{"one", "two", "three"}},
247 {input: "single", want: []string{"single"}},
248 {input: "", want: nil},
249 }
250
251 for _, tt := range tests {
252 t.Run(tt.input, func(t *testing.T) {
253 t.Setenv(testVar, tt.input)
254 desc := env.StringSlice(testVar)
255
256 var result []string
257 require.NoError(t, desc.Parse(&result))
258
259 assert.Equal(t, tt.want, result)
260 })
261 }
262}
263
264func TestStringSliceSep(t *testing.T) {
265 const sepVar = "TEST_SEP_VAR"

Callers

nothing calls this directly

Calls 3

StringSliceFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80

Tested by

no test coverage detected