-
Notifications
You must be signed in to change notification settings - Fork 5
/
imgwizard_test.go
97 lines (90 loc) · 2.38 KB
/
imgwizard_test.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package imgwizard
import "testing"
func TestCachePath(t *testing.T) {
tests := []struct {
CacheDir string
Storage string
Path string
Width int
Height int
CachePath string
}{
{
"/tmp/imgwizard",
"rem",
"media.somesite.ua/uploads/product_image/2015/02/242/c6cc5dd1-6f25-4642-734d-bbf5bef5dffa_8b91c9c17027e331f991ddc7ea3b2dd9_orig.jpg",
320,
240,
"/tmp/imgwizard/media.somesite.ua/uploads/product_image/2015/02/242/c6cc5dd1-6f25-4642-734d-bbf5bef5dffa_8b91c9c17027e331f991ddc7ea3b2dd9_orig_320x240.jpg",
},
{
"/your_cache_path",
"rem",
"media.somesite.ua/uploads/product_image/2015/02/242/c6cc5dd1-6f25-4642-734d-bbf5bef5dffa_8b91c9c17027e331f991ddc7ea3b2dd9_orig.jpg",
320,
240,
"/your_cache_path/media.somesite.ua/uploads/product_image/2015/02/242/c6cc5dd1-6f25-4642-734d-bbf5bef5dffa_8b91c9c17027e331f991ddc7ea3b2dd9_orig_320x240.jpg",
},
{
"/tmp/imgwizard",
"loc",
"media.somesite.ua/uploads/product_image/2015/02/242/c6cc5dd1-6f25-4642-734d-bbf5bef5dffa_8b91c9c17027e331f991ddc7ea3b2dd9_orig.jpg",
320,
240,
"/tmp/imgwizard/media.somesite.ua/uploads/product_image/2015/02/242/c6cc5dd1-6f25-4642-734d-bbf5bef5dffa_8b91c9c17027e331f991ddc7ea3b2dd9_orig_320x240.jpg",
},
{
"/tmp/imgwizard",
"loc",
"media_dir/image_orig.jpg",
320,
240,
"/tmp/imgwizard/media_dir/image_orig_320x240.jpg",
},
{
"/tmp/imgwizard",
"loc",
"m/e/d/i/a_dir/image_orig.jpg",
320,
240,
"/tmp/imgwizard/m/e/d/i/a_dir/image_orig_320x240.jpg",
},
{
"/tmp/imgwizard",
"rem",
"m/e/d/i/a_dir/image_orig.jpg",
0,
240,
"/tmp/imgwizard/m/e/d/i/a_dir/image_orig_0x240.jpg",
},
{
"/tmp/imgwizard",
"loc",
"m/e/d/i/a_dir/image_orig.jpg",
0,
0,
"/tmp/imgwizard/m/e/d/i/a_dir/image_orig_0x0.jpg",
},
{
"/tmp/imgwizard",
"loc",
"m/e/d/i/a_dir/image_orig.jpg?crop=left,top&q=10",
0,
0,
"/tmp/imgwizard/m/e/d/i/a_dir/image_orig_0x0.jpg?crop=left,top&q=10",
},
}
for i, test := range tests {
context := Context{}
CacheDir = test.CacheDir
context.Storage = test.Storage
context.Path = test.Path
context.Options.Width = test.Width
context.Options.Height = test.Height
context.makeCachePath()
CachePath := context.CachePath
if test.CachePath != CachePath {
t.Errorf("%d. makeCachePath returned %v, needed %v", i, CachePath, test.CachePath)
}
}
}