Skip to content

Commit

Permalink
Merge pull request #57 from mjlshen/rocket
Browse files Browse the repository at this point in the history
🐛 Add missing case statements for release PRs
  • Loading branch information
k8s-ci-robot committed Nov 1, 2023
2 parents e389278 + ffe5cac commit 3c34113
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 3c34113

Please sign in to comment.