-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstates_test.go
70 lines (64 loc) · 1.18 KB
/
states_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
package ghx
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestState(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
state State
expectString string
}{
{
state: StateOpen,
expectString: "open",
},
{
state: StateClosed,
expectString: "closed",
},
{
state: StateAll,
expectString: "all",
},
{
state: State(-1),
},
} {
tc := tc
t.Run(fmt.Sprintf("%v == %s", tc.state, tc.expectString), func(t *testing.T) {
t.Parallel()
assert.Equal(t, tc.expectString, *tc.state.StringP())
})
}
}
func TestStateReason(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
stateReason StateReason
expectString string
}{
{
stateReason: StateReasonCompleted,
expectString: "completed",
},
{
stateReason: StateReasonNotPlanned,
expectString: "not_planned",
},
{
stateReason: StateReasonReopened,
expectString: "reopened",
},
{
stateReason: StateReason(-1),
},
} {
tc := tc
t.Run(fmt.Sprintf("%v == %s", tc.stateReason, tc.expectString), func(t *testing.T) {
t.Parallel()
assert.Equal(t, tc.expectString, *tc.stateReason.StringP())
})
}
}