Skip to content

Commit

Permalink
🐛 Fixed Issue Test Cases coverage issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreminiom committed Apr 8, 2021
1 parent a7cc8b1 commit c4bf375
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
13 changes: 9 additions & 4 deletions jira/issue.go
Expand Up @@ -95,11 +95,15 @@ func (i *IssueScheme) MergeOperations(operations *UpdateOperations) (result map[
}

issueSchemeAsMap := make(map[string]interface{})
_ = json.Unmarshal(issueSchemeAsBytes, &issueSchemeAsMap)
if err = json.Unmarshal(issueSchemeAsBytes, &issueSchemeAsMap); err != nil {
return nil, err
}

//For each customField created, merge it into the eAsMap
for _, customField := range operations.Fields {
_ = mergo.Merge(&issueSchemeAsMap, customField, mergo.WithOverride)
if err = mergo.Merge(&issueSchemeAsMap, customField, mergo.WithOverride); err != nil {
return nil, err
}
}

return issueSchemeAsMap, nil
Expand All @@ -111,8 +115,9 @@ func (i *IssueScheme) ToMap() (result map[string]interface{}, err error) {
issueSchemeAsBytes, _ := json.Marshal(i)

issueSchemeAsMap := make(map[string]interface{})
_ = json.Unmarshal(issueSchemeAsBytes, &issueSchemeAsMap)

if err = json.Unmarshal(issueSchemeAsBytes, &issueSchemeAsMap); err != nil {
return nil, err
}
return issueSchemeAsMap, err
}

Expand Down
18 changes: 18 additions & 0 deletions jira/issue_test.go
Expand Up @@ -2531,6 +2531,24 @@ func TestIssueService_Update(t *testing.T) {
wantErr: false,
},

{
name: "UpdateIssueWhenTheOperationsAndCustomFieldsAreNotSetAndContextIsNil",
issueKeyOrID: "DUMMY-3",
notify: false,
payload: &IssueScheme{
Fields: &IssueFieldsScheme{
Summary: "New summary test",
},
},
operations: nil,
customFields: nil,
wantHTTPMethod: http.MethodPut,
endpoint: "/rest/api/3/issue/DUMMY-3?notifyUsers=false",
context: nil,
wantHTTPCodeReturn: http.StatusNoContent,
wantErr: true,
},

{
name: "UpdateIssueWhenTheNotifyParamIsTrue",
issueKeyOrID: "DUMMY-3",
Expand Down

0 comments on commit c4bf375

Please sign in to comment.