-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add template func to remove issue mentions, add RenderCustom
- Loading branch information
1 parent
a362e4e
commit 0964d87
Showing
6 changed files
with
85 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package vcsapp | ||
|
||
import ( | ||
"regexp" | ||
) | ||
|
||
var vcsPattern = regexp.MustCompile(`\s+\(#\d+\)$`) | ||
var jiraPattern = regexp.MustCompile(`\s+\([A-Z]+-\d+\)$`) | ||
|
||
func RemoveIssueMentionFromMessage(text string) string { | ||
text = vcsPattern.ReplaceAllString(text, "") | ||
text = jiraPattern.ReplaceAllString(text, "") | ||
|
||
return text | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package vcsapp | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestRemoveIssueMentionFromMessage(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
expected string | ||
}{ | ||
{"This is a test message (#123)", "This is a test message"}, | ||
{"Another example (#4567)", "Another example"}, | ||
{"No issue mentioned here", "No issue mentioned here"}, | ||
{"Different Style (AB-1234)", "Different Style"}, | ||
} | ||
|
||
for _, test := range tests { | ||
result := RemoveIssueMentionFromMessage(test.input) | ||
if result != test.expected { | ||
t.Errorf("For input '%s', expected '%s', but got '%s'", test.input, test.expected, result) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package vcsapp | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRender(t *testing.T) { | ||
output, err := Render("Test Content: {{ .Content }}", map[string]interface{}{ | ||
"Content": "Example", | ||
}) | ||
expected := "Test Content: Example" | ||
assert.NoError(t, err) | ||
assert.Equal(t, expected, string(output)) | ||
} |