Fix body string check

This commit is contained in:
Sam Park
2020-01-24 20:50:51 -08:00
parent 041c45d4c1
commit fd93af8a55
2 changed files with 7 additions and 6 deletions

View File

@@ -159,7 +159,8 @@ func (g *GithubClient) HideOldComments(repo models.Repo, pullNum int) error {
// a reasonable one, given we've already filtered the comments by the
// configured Atlantis user.
body := strings.Split(comment.GetBody(), "\n")
if !strings.Contains(body[0], models.ApplyCommand.String()) {
firstLine := strings.ToLower(body[0])
if !strings.Contains(firstLine, models.PlanCommand.String()) {
continue
}
var m struct {

View File

@@ -137,14 +137,14 @@ func TestGithubClient_GetModifiedFilesMovedFile(t *testing.T) {
func TestGithubClient_HideOldComments(t *testing.T) {
// Only comment 6 should be minimized, because it's by the same Atlantis bot user
// and it has "apply" in the first line of the comment body.
// and it has "plan" in the first line of the comment body.
issueResp := `[
{"node_id": "1", "body": "asd\napply\nasd", "user": {"login": "someone-else"}},
{"node_id": "2", "body": "asd apply\nasd", "user": {"login": "someone-else"}},
{"node_id": "1", "body": "asd\nplan\nasd", "user": {"login": "someone-else"}},
{"node_id": "2", "body": "asd plan\nasd", "user": {"login": "someone-else"}},
{"node_id": "3", "body": "asdasdasd\nasdasdasd", "user": {"login": "someone-else"}},
{"node_id": "4", "body": "asdasdasd\nasdasdasd", "user": {"login": "user"}},
{"node_id": "5", "body": "asd\napply\nasd", "user": {"login": "user"}},
{"node_id": "6", "body": "asd apply\nasd", "user": {"login": "user"}},
{"node_id": "5", "body": "asd\nplan\nasd", "user": {"login": "user"}},
{"node_id": "6", "body": "asd plan\nasd", "user": {"login": "user"}},
{"node_id": "7", "body": "asdasdasd", "user": {"login": "user"}}
]`
minimizeResp := "{}"