(t *testing.T)
| 262 | } |
| 263 | |
| 264 | func 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 | |
| 301 | func TestURLPath(t *testing.T) { |
| 302 | tests := []struct { |
nothing calls this directly
no test coverage detected