1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-03-17 20:47:57 +02:00

Merge pull request #79 from netxfly/master

Add UpdateIssue method for JIRA 7.4.0
This commit is contained in:
Andy Grunwald 2017-08-16 13:36:43 +02:00 committed by GitHub
commit acbc88d595
2 changed files with 42 additions and 0 deletions

View File

@ -608,6 +608,25 @@ func (s *IssueService) Update(issue *Issue) (*Issue, *Response, error) {
return &ret, resp, nil
}
// Update updates an issue from a JSON representation. The issue is found by key.
//
// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue
func (s *IssueService) UpdateIssue(jiraId string, data map[string]interface{}) (*Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", jiraId)
req, err := s.client.NewRequest("PUT", apiEndpoint, data)
if err != nil {
return nil, err
}
resp, err := s.client.Do(req, nil)
if err != nil {
return resp, err
}
// This is just to follow the rest of the API's convention of returning an issue.
// Returning the same pointer here is pointless, so we return a copy instead.
return resp, nil
}
// AddComment adds a new comment to issueID.
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issue-addComment

View File

@ -103,6 +103,29 @@ func TestIssueService_Update(t *testing.T) {
}
}
func TestIssueService_UpdateIssue(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/rest/api/2/issue/PROJ-9001", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testRequestURL(t, r, "/rest/api/2/issue/PROJ-9001")
w.WriteHeader(http.StatusNoContent)
})
jId := "PROJ-9001"
i := make(map[string]interface{})
fields := make(map[string]interface{})
i["fields"] = fields
resp, err := testClient.Issue.UpdateIssue(jId, i)
if resp == nil {
t.Error("Expected resp. resp is nil")
}
if err != nil {
t.Errorf("Error given: %s", err)
}
}
func TestIssueService_AddComment(t *testing.T) {
setup()
defer teardown()