From eed4e3a54081c6fdcc07b89cae5efca7b9b23a4f Mon Sep 17 00:00:00 2001 From: Alan Yan Date: Thu, 3 Sep 2020 17:24:30 -0400 Subject: [PATCH] NIGH-153 Fix FilterComments Error (#41) * fix bug caused by comments on outdated code * add outdated comment to test --- .../diffreviewer/circleci/circleci_service.go | 12 ++++++------ .../diffreviewer/circleci/circleci_service_test.go | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/clients/diffreviewer/circleci/circleci_service.go b/internal/clients/diffreviewer/circleci/circleci_service.go index bdc6e645..c28126b9 100644 --- a/internal/clients/diffreviewer/circleci/circleci_service.go +++ b/internal/clients/diffreviewer/circleci/circleci_service.go @@ -281,18 +281,18 @@ func filterExistingComments(comments []*github.PullRequestComment, existingComme existingCommentsMap := make(map[prComment]bool, len(existingComments)) for _, ec := range existingComments { comment := prComment{ - Body: *ec.Body, - Path: *ec.Path, - Line: *ec.Line, + Body: ec.GetBody(), + Path: ec.GetPath(), + Line: ec.GetLine(), } existingCommentsMap[comment] = true } filteredComments := make([]*github.PullRequestComment, 0, len(comments)) for _, c := range comments { comment := prComment{ - Body: *c.Body, - Path: *c.Path, - Line: *c.Line, + Body: c.GetBody(), + Path: c.GetPath(), + Line: c.GetLine(), } if _, ok := existingCommentsMap[comment]; !ok { filteredComments = append(filteredComments, c) diff --git a/internal/clients/diffreviewer/circleci/circleci_service_test.go b/internal/clients/diffreviewer/circleci/circleci_service_test.go index 596db231..f9648636 100644 --- a/internal/clients/diffreviewer/circleci/circleci_service_test.go +++ b/internal/clients/diffreviewer/circleci/circleci_service_test.go @@ -444,6 +444,11 @@ func (c *circleCiTestSuite) TestFilterExistingComments() { Path: &pathStrs[2], Line: &lineNums[2], }, + { + Body: &bodyStrs[0], + Path: &pathStrs[0], + Line: nil, + }, } newComment1 := &github.PullRequestComment{ Body: &bodyStrs[0],