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

Function TestURLPath

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

Source from the content-addressed store, hash-verified

299}
300
301func TestURLPath(t *testing.T) {
302 tests := []struct {
303 input string
304 want string
305 }{
306 {input: "path/to/resource", want: "/path/to/resource"},
307 {input: "/path/to/resource/", want: "/path/to/resource"},
308 {input: "/path?query=value", want: "/path"},
309 {input: "/path#fragment", want: "/path"},
310 {input: "path/to/resource/?query=value#fragment", want: "/path/to/resource"},
311 {input: "", want: ""},
312 }
313
314 for _, tt := range tests {
315 t.Run(tt.input+"=>"+tt.want, func(t *testing.T) {
316 t.Setenv(testVar, tt.input)
317 desc := env.URLPath(testVar)
318
319 var result string
320 require.NoError(t, desc.Parse(&result))
321
322 assert.Equal(t, tt.want, result)
323 })
324 }
325}
326
327func TestImageTypes(t *testing.T) {
328 tests := []struct {

Callers

nothing calls this directly

Calls 3

URLPathFunction · 0.92
RunMethod · 0.80
ParseMethod · 0.80

Tested by

no test coverage detected