This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
forked from imgproxy/imgproxy
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprocess_test.go
87 lines (78 loc) · 1.92 KB
/
process_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
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/url"
"testing"
"time"
)
const dataDir = "testdata"
func loadTestData(t *testing.T, inFile string, outFile string) ([]byte, []byte) {
in, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", dataDir, inFile))
if err != nil {
t.Fatal(err)
}
out, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", dataDir, outFile))
if err != nil {
t.Fatal(err)
}
return in, out
}
func Test_thumbnail(t *testing.T) {
in, out := loadTestData(t, "in0.png", "out0.png")
timer := startTimer(time.Duration(1) * time.Second, "Processing")
result, err := processImage(in, "image/png", 500, 100, timer)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(out, result) {
t.Fatal("Unexpected output.")
}
}
func Test_PDF_PNG(t *testing.T) {
in, out := loadTestData(t, "in1.pdf", "out1.png")
result, _, err := extractPDFPage(in, "dummy", 3, "image/png")
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(out, result) {
t.Fatal("Unexpected output.")
}
}
func Test_GLTF_GLTF_rewrite(t *testing.T) {
in, out := loadTestData(t, "in2.gltf", "out2.gltf")
baseURL, err := url.Parse("https://asset-bundles-prod.reticulum.io/rooms/atrium/AtriumMeshes-5f8fb06d92.gltf")
if err != nil {
t.Fatal(err)
}
serverURL, err := url.Parse("http://localhost:8080")
if err != nil {
t.Fatal(err)
}
result, err := processGLTF(in, baseURL, serverURL)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(out, result) {
t.Fatal("Unexpected output.")
}
}
func Test_GLTF_GLTF_no_images(t *testing.T) {
in, out := loadTestData(t, "in3.gltf", "out3.gltf")
baseURL, err := url.Parse("https://poly.googleapis.com/downloads/2PDe5PSncTC/bM1VRy9M_TP/Wolf_01.gltf")
if err != nil {
t.Fatal(err)
}
serverURL, err := url.Parse("http://localhost:8080")
if err != nil {
t.Fatal(err)
}
result, err := processGLTF(in, baseURL, serverURL)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(out, result) {
t.Fatal("Unexpected output.")
}
}