From ffe5cac96c4aed93effacd6e4cbb5d595d309f77 Mon Sep 17 00:00:00 2001 From: Michael Shen Date: Tue, 31 Oct 2023 13:20:02 -0400 Subject: [PATCH] Add missing case statements for release PRs Signed-off-by: Michael Shen --- notes/common/prefix.go | 4 ++++ verify/type_test.go | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/notes/common/prefix.go b/notes/common/prefix.go index 967f8ae..9e8246a 100644 --- a/notes/common/prefix.go +++ b/notes/common/prefix.go @@ -37,6 +37,8 @@ func (t PRType) Emoji() string { return emojiDocs case InfraPR: return emojiInfra + case ReleasePR: + return emojiRelease default: panic(fmt.Sprintf("unrecognized PR type %v", t)) } @@ -55,6 +57,8 @@ func (t PRType) String() string { return "docs" case InfraPR: return "infra" + case ReleasePR: + return "release" default: panic(fmt.Sprintf("unrecognized PR type %d", int(t))) } diff --git a/verify/type_test.go b/verify/type_test.go index ca72905..0fd5961 100644 --- a/verify/type_test.go +++ b/verify/type_test.go @@ -16,7 +16,45 @@ limitations under the License. package main -import "testing" +import ( + "github.com/google/go-github/v32/github" + "testing" +) + +func stringPointer(s string) *string { + return &s +} + +func Test_verifyPRType(t *testing.T) { + tests := []struct { + name string + pr *github.PullRequest + want string + }{ + { + name: "Bugfix PR", + pr: &github.PullRequest{ + Title: stringPointer(":bug: Fixing bug"), + }, + want: "Found 🐛 PR (bugfix)", + }, + { + name: "Release PR", + pr: &github.PullRequest{ + Title: stringPointer(":rocket: Release v0.0.1"), + }, + want: "Found 🚀 PR (release)", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got, _, _ := verifyPRType(tt.pr); got != tt.want { + t.Errorf("verifyPRType() = %v, want %v", got, tt.want) + } + }) + } +} func Test_trimTitle(t *testing.T) { tests := []struct {