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
|
package main
import (
"testing"
"github.com/alecthomas/assert/v2"
)
func TestClassifyStatus(t *testing.T) {
testcases := map[string]struct {
Str string
Err string
}{
"merged+deployed": {"released", ""},
"merged, deployed": {"released", ""},
"released in v1.2": {"released", ""},
"merged, released in v1.2": {"released", ""},
statusReleasedFmt: {"released", ""},
"merged": {"merged", ""},
statusMerged: {"merged", ""},
"open": {"open", ""},
"closed": {"closed", ""},
"locked": {"closed", ""},
}
for in, exp := range testcases {
t.Run(in, func(t *testing.T) {
actStr, actErr := classifyStatus(in)
assert.Equal(t, exp.Str, actStr)
if exp.Err == "" {
assert.NoError(t, actErr)
} else {
assert.EqualError(t, actErr, exp.Err)
}
})
}
}
|