-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathavatar_picture_test.go
47 lines (36 loc) · 1.05 KB
/
avatar_picture_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
package avatar
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPicture_Circle(t *testing.T) {
size := 200
mascotPath := getTestResource("test_data", "super_mascot.jpg")
fileBytes, err := ioutil.ReadFile(mascotPath)
assert.NoError(t, err)
newAvatar, err := NewAvatarFromPic(fileBytes, &PictureOptions{
Size: size,
})
assert.NoError(t, err)
round, err := newAvatar.Circle()
roundMascotPath := getTestResource("output", "round_super_mascot.png")
roundFile, err := os.Create(roundMascotPath)
assert.NoError(t, err)
roundFile.Write(round)
}
func TestPicture_Square(t *testing.T) {
size := 200
mascotPath := getTestResource("test_data", "super_mascot.jpg")
fileBytes, err := ioutil.ReadFile(mascotPath)
assert.NoError(t, err)
newAvatar, _ := NewAvatarFromPic(fileBytes, &PictureOptions{
Size: size,
})
square, err := newAvatar.Square()
squareMascotPath := getTestResource("output", "square_super_mascot.png")
squareFile, err := os.Create(squareMascotPath)
assert.NoError(t, err)
squareFile.Write(square)
}