@@ -12,7 +12,7 @@ func TestBuildCommitCommand(t *testing.T) {
12
12
}
13
13
}
14
14
15
- func TestMatchTicketNumber (t * testing.T ) {
15
+ func TestCheckBoardMatchesBranch (t * testing.T ) {
16
16
cases := []struct {
17
17
Desc string
18
18
msg string
@@ -24,16 +24,38 @@ func TestMatchTicketNumber(t *testing.T) {
24
24
{"it should match with 4 digits" , "TICKET-1234" , true },
25
25
{"it should match with 5 digits" , "TICKET-12345" , true },
26
26
{"it should match with 6 digits" , "TICKET-123456" , true },
27
+ {"it should match different case" , "ticket-1234" , true },
28
+ {"it should match different format" , "fix-for-TICKET-1234" , true },
29
+ {"it should not match with no digits" , "TICKET-" , false },
27
30
}
28
31
29
32
for _ , tc := range cases {
30
33
t .Run (tc .Desc , func (t * testing.T ) {
31
- got := matchTicketNumber ("TICKET" , tc .msg )
34
+ got := checkBoardMatchesBranch ("TICKET" , tc .msg )
32
35
assertEqualBools (t , tc .want , got )
33
36
})
34
37
}
35
38
}
36
39
40
+ func TestGetTicketNumberFromString (t * testing.T ) {
41
+ cases := []struct {
42
+ Desc string
43
+ msg string
44
+ sub string
45
+ want string
46
+ }{
47
+ {"it should return the ticket number" , "TICKET-1234" , "TICKET" , "TICKET-1234" },
48
+ {"it should return when ticket is not at the beginning" , "this is a TICKET-1234" , "TICKET" , "TICKET-1234" },
49
+ }
50
+
51
+ for _ , tc := range cases {
52
+ t .Run (tc .Desc , func (t * testing.T ) {
53
+ got := getTicketNumberFromString (tc .msg , tc .sub )
54
+ assertEqualStrings (t , tc .want , got )
55
+ })
56
+ }
57
+ }
58
+
37
59
func assertEqualStrings (t testing.TB , expected , got string ) {
38
60
t .Helper ()
39
61
if got != expected {
0 commit comments