-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathavatar_initials_test.go
49 lines (39 loc) · 1.13 KB
/
avatar_initials_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
package avatar
import (
"image/color"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestInitials_Circle(t *testing.T) {
size := 200
newAvatar, err := NewAvatarFromInitials([]byte("John Smith"), &InitialsOptions{
Size: size,
NInitials: 2,
FontPath: getTestResource("test_data", "Arial.ttf"),
})
assert.NoError(t, err)
round, err := newAvatar.Circle()
assert.NoError(t, err)
roundOutputPath := getTestResource("output", "round_john_smith_initials.png")
roundFile, err := os.Create(roundOutputPath)
assert.NoError(t, err)
roundFile.Write(round)
}
func TestInitials_Square(t *testing.T) {
size := 200
newAvatar, err := NewAvatarFromInitials([]byte("John Smith"), &InitialsOptions{
Size: size,
NInitials: 2,
FontPath: getTestResource("test_data", "Arial.ttf"),
TextColor: color.White,
BgColor: color.RGBA{0, 0, 255, 255},
})
assert.NoError(t, err)
square, err := newAvatar.Square()
assert.NoError(t, err)
squareOutputPath := getTestResource("output", "square_john_smith_initials.png")
squareFile, err := os.Create(squareOutputPath)
assert.NoError(t, err)
squareFile.Write(square)
}