Skip to content

Commit ffe5cac

Browse files
committed
Add missing case statements for release PRs
Signed-off-by: Michael Shen <[email protected]>
1 parent e389278 commit ffe5cac

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

notes/common/prefix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func (t PRType) Emoji() string {
3737
return emojiDocs
3838
case InfraPR:
3939
return emojiInfra
40+
case ReleasePR:
41+
return emojiRelease
4042
default:
4143
panic(fmt.Sprintf("unrecognized PR type %v", t))
4244
}
@@ -55,6 +57,8 @@ func (t PRType) String() string {
5557
return "docs"
5658
case InfraPR:
5759
return "infra"
60+
case ReleasePR:
61+
return "release"
5862
default:
5963
panic(fmt.Sprintf("unrecognized PR type %d", int(t)))
6064
}

verify/type_test.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,45 @@ limitations under the License.
1616

1717
package main
1818

19-
import "testing"
19+
import (
20+
"github.com/google/go-github/v32/github"
21+
"testing"
22+
)
23+
24+
func stringPointer(s string) *string {
25+
return &s
26+
}
27+
28+
func Test_verifyPRType(t *testing.T) {
29+
tests := []struct {
30+
name string
31+
pr *github.PullRequest
32+
want string
33+
}{
34+
{
35+
name: "Bugfix PR",
36+
pr: &github.PullRequest{
37+
Title: stringPointer(":bug: Fixing bug"),
38+
},
39+
want: "Found 🐛 PR (bugfix)",
40+
},
41+
{
42+
name: "Release PR",
43+
pr: &github.PullRequest{
44+
Title: stringPointer(":rocket: Release v0.0.1"),
45+
},
46+
want: "Found 🚀 PR (release)",
47+
},
48+
}
49+
50+
for _, tt := range tests {
51+
t.Run(tt.name, func(t *testing.T) {
52+
if got, _, _ := verifyPRType(tt.pr); got != tt.want {
53+
t.Errorf("verifyPRType() = %v, want %v", got, tt.want)
54+
}
55+
})
56+
}
57+
}
2058

2159
func Test_trimTitle(t *testing.T) {
2260
tests := []struct {

0 commit comments

Comments
 (0)