Skip to content

Commit 6d3eb27

Browse files
committed
updated tests
1 parent 48aedc4 commit 6d3eb27

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

imagekit_test.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestUrl(t *testing.T) {
6565
},
6666
url: "https://imagekit.io/343534/tr:w-100,rt-90/default-image.jpg",
6767
}, {
68-
name: "signed-without-transformation",
68+
name: "signed-url",
6969
params: ikurl.UrlParam{
7070
Path: "default-image.jpg",
7171
Signed: true,
@@ -75,24 +75,6 @@ func TestUrl(t *testing.T) {
7575
},
7676
},
7777
url: "https://ik.imagekit.io/test/default-image.jpg?ik-t=1653775928&ik-s=48842eca663c6895331331db6c90f262c601f4e8",
78-
}, {
79-
name: "signed-with-transformation",
80-
params: ikurl.UrlParam{
81-
Path: "default-image.jpg",
82-
UrlEndpoint: "https://ik.imagekit.io/test/",
83-
Transformations: []map[string]any{
84-
{
85-
"width": 200,
86-
"rotation": 90,
87-
},
88-
},
89-
Signed: true,
90-
ExpireSeconds: 100,
91-
UnixTime: func() int64 {
92-
return 1653775828
93-
},
94-
},
95-
url: "https://ik.imagekit.io/test/tr:w-200,rt-90/default-image.jpg?ik-t=1653775928&ik-s=6c74b32f5efc0cc39ab5c042718b36553d8a1606",
9678
}, {
9779
name: "src-with-transformation",
9880
params: ikurl.UrlParam{
@@ -308,8 +290,13 @@ func extractTransformation(t *testing.T, url string) (urlResult string, trResult
308290
}
309291

310292
urlResult = strings.Replace(url, "tr:"+m[1], "", 1)
311-
trResult = strings.Split(m[1], ",")
312-
sort.Strings(trResult)
293+
trs := strings.Split(m[1], ":")
294+
295+
for _, tr := range trs {
296+
parts := strings.Split(tr, ",")
297+
sort.Strings(parts)
298+
trResult = append(trResult, parts...)
299+
}
313300

314301
return urlResult, trResult
315302
}
@@ -331,7 +318,7 @@ func urlsEquals(url1 string, url2 string) bool {
331318
return reflect.DeepEqual(q1, q2)
332319
}
333320

334-
func TestSignToken(t *testing.T) {
321+
func Test_SignToken(t *testing.T) {
335322
var expire int64 = 1655379249 + DefaultTokenExpire
336323
var unix = func() int64 { return 1655379249 }
337324
var token = "xxxx-xxxx-xxxxxxxx"

0 commit comments

Comments
 (0)