forked from rnorth/gh-combine-prs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitle_test.go
93 lines (90 loc) · 2.07 KB
/
title_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
package main
import "testing"
func TestCombineTitles(t *testing.T) {
tests := []struct {
name string
prs []PullRequest
want string
}{
{
name: "Dependabot: single PR",
prs: []PullRequest{
{
Title: "chore(deps): update baaz from 3.2.1 to 3.2.2 in /",
},
},
want: "chore(deps): update baaz from 3.2.1 to 3.2.2 in /",
},
{
name: "Non-Dependabot: single PR",
prs: []PullRequest{
{
Title: "feat: implement features",
},
},
want: "feat: implement features",
},
{
name: "Multiple dependabot PRs with bump",
prs: []PullRequest{
{
Title: "chore(deps): bump foo from 1.0.0 to 1.0.1 in /",
},
{
Title: "chore(deps): bump bar from 1.0.0 to 1.0.1 in /modules/bar",
},
{
Title: "chore(deps): update baaz from 3.2.1 to 3.2.2 in /",
},
{
Title: "chore(deps): bump faag from 1.0.0 to 1.0.1 in /foo",
},
},
want: "chore(deps): bump foo from 1.0.0 to 1.0.1 in /, bar from 1.0.0 to 1.0.1 in /modules/bar, baaz from 3.2.1 to 3.2.2 in /, faag from 1.0.0 to 1.0.1 in /foo",
},
{
name: "Multiple dependabot PRs with update",
prs: []PullRequest{
{
Title: "chore(deps): update foo from 1.0.0 to 1.0.1 in /",
},
{
Title: "chore(deps): bump bar from 1.0.0 to 1.0.1 in /modules/bar",
},
{
Title: "chore(deps): bump baaz from 3.2.1 to 3.2.2 in /",
},
{
Title: "chore(deps): bump faag from 1.0.0 to 1.0.1 in /foo",
},
},
want: "chore(deps): update foo from 1.0.0 to 1.0.1 in /, bar from 1.0.0 to 1.0.1 in /modules/bar, baaz from 3.2.1 to 3.2.2 in /, faag from 1.0.0 to 1.0.1 in /foo",
},
{
name: "Multiple PRs with bump",
prs: []PullRequest{
{
Title: "feat 1",
},
{
Title: "feat 2",
},
{
Title: "chore 1",
},
{
Title: "chore 2",
},
},
want: "feat 1, feat 2, chore 1, chore 2",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
title := combineTitles(tt.prs)
if title != tt.want {
t.Errorf("expected %q, got %q", tt.want, title)
}
})
}
}