Skip to content

Commit

Permalink
test: add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
npepinpe authored and menski committed Dec 7, 2021
1 parent 1a80485 commit e41cfca
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions pkg/gitlog/gitlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@ func TestExtractIssueIds(t *testing.T) {
message string
issueIds []int
}{
"No issue id": {message: "hello world", issueIds: nil},
"No keyword": {message: "#1234", issueIds: nil},
"Close keyword": {message: "close #1234", issueIds: []int{1234}},
"Closes keyword": {message: "closes #1234", issueIds: []int{1234}},
"Related keyword": {message: "related #1234", issueIds: []int{1234}},
"Merge keyword": {message: "merge #1234", issueIds: []int{1234}},
"Merges keyword": {message: "merges #1234", issueIds: []int{1234}},
"Relates keyword": {message: "relates to #1234", issueIds: []int{1234}},
"Backport keyword": {message: "backport #1234", issueIds: []int{1234}},
"Backports keyword": {message: "backports #1234", issueIds: []int{1234}},
"Back ports keyword": {message: "back ports #1234", issueIds: []int{1234}},
"Keyword uppercase": {message: "Closes #1234", issueIds: []int{1234}},
"Spacing in front of keyword": {message: " \t closes #1234", issueIds: []int{1234}},
"Multiple issues": {message: "closes #1234, #5678, #9 and #123", issueIds: []int{1234, 5678, 9, 123}},
"Duplicate issue ids": {message: "closes #123, #234, #123 and #23", issueIds: []int{123, 234, 23}},
"Multiple lines": {message: "foo bar\n\ncloses #1234\ntest", issueIds: []int{1234}},
"No issue id": {message: "hello world", issueIds: nil},
"No keyword": {message: "#1234", issueIds: nil},
"Close keyword": {message: "close #1234", issueIds: []int{1234}},
"Closes keyword": {message: "closes #1234", issueIds: []int{1234}},
"Related keyword": {message: "related #1234", issueIds: []int{1234}},
"Merge keyword": {message: "merge #1234", issueIds: []int{1234}},
"Merges keyword": {message: "merges #1234", issueIds: []int{1234}},
"Relates keyword": {message: "relates to #1234", issueIds: []int{1234}},
"Backport keyword": {message: "backport #1234", issueIds: []int{1234}},
"Backports keyword": {message: "backports #1234", issueIds: []int{1234}},
"Back ports keyword": {message: "back ports #1234", issueIds: []int{1234}},
"Keyword uppercase": {message: "Closes #1234", issueIds: []int{1234}},
"Spacing in front of keyword": {message: " \t closes #1234", issueIds: []int{1234}},
"Multiple issues": {message: "closes #1234, #5678, #9 and #123", issueIds: []int{1234, 5678, 9, 123}},
"Duplicate issue ids": {message: "closes #123, #234, #123 and #23", issueIds: []int{123, 234, 23}},
"Multiple lines": {message: "foo bar\n\ncloses #1234\ntest", issueIds: []int{1234}},
"Multiple IDs without keywords": {message: "foo\n\nbar #234\n\nmerges #1", issueIds: []int{1}},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit e41cfca

Please sign in to comment.