-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
62 lines (44 loc) · 1.13 KB
/
options_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
package identicon_test
import (
"crypto/sha1"
"image/color"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tsdtsdtsd/identicon"
)
func TestWithBGColorOption(t *testing.T) {
red := color.NRGBA{255, 0, 0, 255}
optionFunc := identicon.WithBGColor(red)
icon, err := identicon.New("id")
optionFunc(icon)
got := icon.Options().BGColor
assert.NoError(t, err)
assert.Equal(t, red, got)
}
func TestWithFGColorOption(t *testing.T) {
red := color.NRGBA{255, 0, 0, 255}
optionFunc := identicon.WithFGColor(red)
icon, err := identicon.New("id")
optionFunc(icon)
got := icon.Options().FGColor
assert.NoError(t, err)
assert.Equal(t, red, got)
}
func TestWithImageSizeOption(t *testing.T) {
size := 200
optionFunc := identicon.WithImageSize(size)
icon, err := identicon.New("id")
optionFunc(icon)
got := icon.Options().ImageSize
assert.NoError(t, err)
assert.Equal(t, size, got)
}
func TestWithHasher(t *testing.T) {
hasher := sha1.New()
optionFunc := identicon.WithHasher(hasher)
icon, err := identicon.New("id")
optionFunc(icon)
got := icon.Options().Hasher
assert.NoError(t, err)
assert.Equal(t, hasher, got)
}