-
Notifications
You must be signed in to change notification settings - Fork 4
/
enum_test.go
95 lines (85 loc) · 1.69 KB
/
enum_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
88
89
90
91
92
93
94
95
package bump_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
bump "github.com/johnmanjiro13/gh-bump"
)
func TestBumpType_String(t *testing.T) {
bumpType := bump.BumpType("major")
assert.Equal(t, "major", bumpType.String())
}
func TestBumpType_IsBlank(t *testing.T) {
tests := map[string]struct {
bumpType bump.BumpType
want bool
}{
"major": {
bumpType: bump.Major,
want: false,
},
"blank": {
bumpType: bump.Blank,
want: true,
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
assert.Equal(t, tt.want, tt.bumpType.IsBlank())
})
}
}
func TestBumpType_Valid(t *testing.T) {
tests := map[string]struct {
bumpType string
want error
}{
"major": {
bumpType: "major",
want: nil,
},
"minor": {
bumpType: "minor",
want: nil,
},
"patch": {
bumpType: "patch",
want: nil,
},
"invalid": {
bumpType: "invalid",
want: fmt.Errorf("%w: got invalid", bump.ErrInvalidBumpType),
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
bumpType := bump.BumpType(tt.bumpType)
assert.Equal(t, tt.want, bumpType.Valid())
})
}
}
func TestParseBumpType(t *testing.T) {
tests := map[string]struct {
s string
want bump.BumpType
wantErr error
}{
"major": {
s: "major",
want: bump.BumpType("major"),
wantErr: nil,
},
"invalid": {
s: "invalid",
want: "",
wantErr: fmt.Errorf("%w: got invalid", bump.ErrInvalidBumpType),
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
got, err := bump.ParseBumpType(tt.s)
assert.Equal(t, tt.want, got)
assert.Equal(t, tt.wantErr, err)
})
}
}