-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgopster_test.go
44 lines (37 loc) · 873 Bytes
/
gopster_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
package gopster
import (
"image/jpeg"
"os"
"testing"
)
func TestGopster(t *testing.T) {
c, err := NewChart(
ShowTitles(),
Width(3),
Height(3),
BackgroundColor("#c98a2a"),
)
if err != nil {
t.Fatalf("Error creating new chart: %s", err.Error())
}
f, err := os.Open("testdata/bomb.jpg")
if err != nil {
t.Fatalf("Error opening test image: %s", err.Error())
}
defer f.Close()
img, err := jpeg.Decode(f)
if err != nil {
t.Fatalf("Error decoding test image: %s", err.Error())
}
for i := 0; i < 9; i++ {
c.MustAddItem("Three Cheers for Disappointment", "The Arrogant Sons of Bitches", img)
}
newImg := c.Generate()
out, err := os.Create("out.jpg")
if err != nil {
t.Fatalf("Error creating new file: %s", err.Error())
}
if err := jpeg.Encode(out, newImg, nil); err != nil {
t.Fatalf("Error encoding new image: %s", err.Error())
}
}