forked from imgproxy/imgproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_path_test.go
More file actions
44 lines (40 loc) · 1.07 KB
/
fix_path_test.go
File metadata and controls
44 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFixPath(t *testing.T) {
tests := []struct {
input string
expected string
}{
{
input: "/signature/width:100/height:100/plain/http:/example.com/image.jpg",
expected: "/signature/width:100/height:100/plain/http://example.com/image.jpg",
},
{
input: "/signature/width:100/height:100/plain/local:/image.jpg",
expected: "/signature/width:100/height:100/plain/local:///image.jpg",
},
{
input: "/signature/width%3A100/height%3A100/plain/local:/image.jpg",
expected: "/signature/width:100/height:100/plain/local:///image.jpg",
},
{
input: "/signature/width%3A100/height%3A100/abc/abc",
expected: "/signature/width:100/height:100/abc/abc",
},
{
input: "/signature/width%3A100/height%3A100/plain/",
expected: "/signature/width:100/height:100/plain/",
},
}
for _, test := range tests {
actual := fixPath(test.input)
require.Equal(
t, test.expected, actual,
"fixPath(%q) = %q; expected %q",
test.input, actual, test.expected,
)
}
}