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

Function TestStringSliceSep

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

Source from the content-addressed store, hash-verified

262}
263
264func TestStringSliceSep(t *testing.T) {
265 const sepVar = "TEST_SEP_VAR"
266
267 tests := []struct {
268 sep string
269 input string
270 want []string
271 }{
272 {sep: "|", input: "one|two|three", want: []string{"one", "two", "three"}},
273 {sep: "", input: "one,two,three", want: []string{"one", "two", "three"}},
274 {
275 sep: ";",
276 input: " one ; two ; three ",
277 want: []string{"one", "two", "three"},
278 },
279 {sep: "", input: "", want: nil},
280 }
281
282 for _, tt := range tests {
283 name := tt.input + "=>" + fmt.Sprint(tt.want)
284 t.Run(name, func(t *testing.T) {
285 if tt.sep != "" {
286 t.Setenv(sepVar, tt.sep)
287 }
288 t.Setenv(testVar, tt.input)
289
290 sepDesc := env.String(sepVar)
291 desc := env.StringSliceSep(testVar, sepDesc)
292
293 var result []string
294 require.NoError(t, desc.Parse(&result))
295
296 assert.Equal(t, tt.want, result)
297 })
298 }
299}
300
301func TestURLPath(t *testing.T) {
302 tests := []struct {

Callers

nothing calls this directly

Calls 4

StringFunction · 0.92
StringSliceSepFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80

Tested by

no test coverage detected