Skip to content

Commit

Permalink
✅ Increased the coverage adding more Test on the issueComment.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreminiom committed Mar 24, 2021
1 parent 15a6f0d commit c47be5e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 0 additions & 4 deletions jira/issueComment.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,6 @@ func (n *CommentNodeScheme) AppendNode(node *CommentNodeScheme) {
n.Content = append(n.Content, node)
}

func (n *CommentNodeScheme) AddendMark(mark *MarkScheme) {
n.Marks = append(n.Marks, mark)
}

type MarkScheme struct {
Type string `json:"type"`
Attrs map[string]interface{} `json:"attrs"`
Expand Down
31 changes: 29 additions & 2 deletions jira/issueComment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,28 @@ func TestCommentService_Delete(t *testing.T) {
wantHTTPCodeReturn: http.StatusBadRequest,
wantErr: true,
},

{
name: "DeleteIssueCommentWhenTheContextIsNil",
issueKeyOrID: "DUMMY-3",
commentID: "10001",
wantHTTPMethod: http.MethodDelete,
endpoint: "/rest/api/3/issue/DUMMY-3/comment/10001",
context: nil,
wantHTTPCodeReturn: http.StatusNoContent,
wantErr: true,
},

{
name: "DeleteIssueCommentWhenTheEndpointIsEmpty",
issueKeyOrID: "DUMMY-3",
commentID: "10001",
wantHTTPMethod: http.MethodDelete,
endpoint: "",
context: context.Background(),
wantHTTPCodeReturn: http.StatusNoContent,
wantErr: true,
},
}

for _, testCase := range testCases {
Expand Down Expand Up @@ -553,6 +575,11 @@ func TestCommentService_Add(t *testing.T) {
{
Type: "text",
Text: "Carlos Test",
Marks: []*MarkScheme{
{
Type: "strong",
},
},
},
{
Type: "emoji",
Expand Down Expand Up @@ -587,10 +614,10 @@ func TestCommentService_Add(t *testing.T) {
visibilityType: "role",
visibilityValue: "Administrators",
body: &commentBody,
expands: []string{"renderedBody"},
expands: []string{"renderedBody", "comment.id"},
mockFile: "./mocks/get-issue-comment-by-id.json",
wantHTTPMethod: http.MethodPost,
endpoint: "/rest/api/3/issue/DUMMY-3/comment?expand=renderedBody",
endpoint: "/rest/api/3/issue/DUMMY-3/comment?expand=renderedBody%2Ccomment.id",
context: context.Background(),
wantHTTPCodeReturn: http.StatusCreated,
wantErr: false,
Expand Down

0 comments on commit c47be5e

Please sign in to comment.