-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimage_specifier_test.go
73 lines (62 loc) · 1.89 KB
/
image_specifier_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
package main
import (
_ "fmt"
"testing"
"github.com/thraxil/resize"
)
func Test_Create(t *testing.T) {
s := "112e42f26fce70d268438ac8137d81607499ee10/200s/1250.jpg"
i := newImageSpecifier(s)
if i.Extension != ".jpg" {
t.Error("wrong extension")
}
}
func Test_String(t *testing.T) {
s := "112e42f26fce70d268438ac8137d81607499ee10/200s/1250.jpg"
i := newImageSpecifier(s)
if i.String() != "112e42f26fce70d268438ac8137d81607499ee10/200s/image.jpg" {
t.Error("incorrect stringification")
}
}
func Test_FullSizePath(t *testing.T) {
s := "112e42f26fce70d268438ac8137d81607499ee10/200s/1250.jpg"
i := newImageSpecifier(s)
r := i.fullSizePath("")
if r != "11/2e/42/f2/6f/ce/70/d2/68/43/8a/c8/13/7d/81/60/74/99/ee/10/full.jpg" {
t.Errorf("wrong fullSizePath: %s", r)
}
}
func Test_SizedPath(t *testing.T) {
s := "112e42f26fce70d268438ac8137d81607499ee10/200s/1250.jpg"
i := newImageSpecifier(s)
r := i.sizedPath("")
if r != "11/2e/42/f2/6f/ce/70/d2/68/43/8a/c8/13/7d/81/60/74/99/ee/10/200s.jpg" {
t.Errorf("wrong sizedPath: %s", r)
}
ahash, _ := hashFromString("112e42f26fce70d268438ac8137d81607499ee10", "")
i = &imageSpecifier{
ahash,
resize.MakeSizeSpec("full"),
".jpg",
}
r = i.sizedPath("")
if r != "11/2e/42/f2/6f/ce/70/d2/68/43/8a/c8/13/7d/81/60/74/99/ee/10/full.jpg" {
t.Errorf("wrong sizedPath: %s", r)
}
}
func Test_RetrieveUrlPath(t *testing.T) {
s := "112e42f26fce70d268438ac8137d81607499ee10/200s/1250.jpg"
i := newImageSpecifier(s)
r := i.retrieveURLPath()
if r != "/retrieve/112e42f26fce70d268438ac8137d81607499ee10/200s/jpg/" {
t.Errorf("wrong retrieveURLPath: %s", r)
}
}
func Test_RetrieveInfoUrlPath(t *testing.T) {
s := "112e42f26fce70d268438ac8137d81607499ee10/200s/1250.jpg"
i := newImageSpecifier(s)
r := i.retrieveInfoURLPath()
if r != "/retrieve_info/112e42f26fce70d268438ac8137d81607499ee10/200s/.jpg/" {
t.Errorf("wrong retreiveInfoUrlPath: %s", r)
}
}