Skip to content

Commit

Permalink
Add missing case statements for release PRs
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Shen <[email protected]>
  • Loading branch information
mjlshen committed Oct 31, 2023
1 parent e389278 commit ffe5cac
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 4 additions & 0 deletions notes/common/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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)))
}
Expand Down
40 changes: 39 additions & 1 deletion verify/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ffe5cac

Please sign in to comment.