forked from stefanlogue/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_test.go
49 lines (43 loc) · 1.17 KB
/
git_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
package main
import "testing"
func TestBuildCommitCommand(t *testing.T) {
msg := "test"
body := "test body"
expected := "git commit -m test -m 'test body'"
_, got := buildCommitCommand(msg, body, nil)
if got != expected {
t.Errorf("expected %s, got %s", expected, got)
}
}
func TestMatchTicketNumber(t *testing.T) {
cases := []struct {
Desc string
msg string
want bool
}{
{"it should match with 1 digit", "TICKET-1", true},
{"it should match with 2 digits", "TICKET-12", true},
{"it should match with 3 digits", "TICKET-123", true},
{"it should match with 4 digits", "TICKET-1234", true},
{"it should match with 5 digits", "TICKET-12345", true},
{"it should match with 6 digits", "TICKET-123456", true},
}
for _, tc := range cases {
t.Run(tc.Desc, func(t *testing.T) {
got := matchTicketNumber("TICKET", tc.msg)
assertEqualBools(t, tc.want, got)
})
}
}
func assertEqualStrings(t testing.TB, expected, got string) {
t.Helper()
if got != expected {
t.Errorf("expected %s, got %s", expected, got)
}
}
func assertEqualBools(t testing.TB, expected, got bool) {
t.Helper()
if got != expected {
t.Errorf("expected %t, got %t", expected, got)
}
}