Skip to content

Instantly share code, notes, and snippets.

@cocotton
Created March 14, 2017 20:11
Show Gist options
  • Save cocotton/2a154706d654033dff6ff622827d234a to your computer and use it in GitHub Desktop.
Save cocotton/2a154706d654033dff6ff622827d234a to your computer and use it in GitHub Desktop.
var testPRMessageTests = []struct {
message string
expected error
}{
{"Merge pull request #4 in ABC/def from some_branch to master\n\nMerge comment\n\n* commit '1h2e09d3029370d92723'", nil},
{"Merge pull request #4 in ABC/def from some_branch to master\n", %%%WHAT_COMES_HERE%%%},
}
func TestTestPRMessage(t *testing.T) {
for _, test := range testPRMessageTests {
actual := testPRMessage(test.message)
if actual != test.expected {
t.Errorf("getPRMessage(%s) - expected: %s, actual: %s", test.message, test.expected, actual)
}
}
}
func testPRMessage(gitMessage string) error {
//var err error
if len(strings.Split(gitMessage, "\n")) < 3 {
return errors.New("Malformated pull request. Cannot find merge comment.")
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment