mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-05-29 22:48:15 +02:00
feat: add worklog update method
Allows updating work log entries API reference url: https://docs.atlassian.com/software/jira/docs/api/REST/7.1.2/#api/2/issue-updateWorklog
This commit is contained in:
parent
7530b7cd82
commit
9ff562ae3e
27
issue.go
27
issue.go
@ -868,6 +868,33 @@ func (s *IssueService) AddWorklogRecord(issueID string, record *WorklogRecord, o
|
||||
return responseRecord, resp, nil
|
||||
}
|
||||
|
||||
// UpdateWorklogRecord updates a worklog record.
|
||||
//
|
||||
// https://docs.atlassian.com/software/jira/docs/api/REST/7.1.2/#api/2/issue-updateWorklog
|
||||
func (s *IssueService) UpdateWorklogRecord(issueID, worklogID string, record *WorklogRecord, options ...func(*http.Request) error) (*WorklogRecord, *Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/worklog/%s", issueID, worklogID)
|
||||
req, err := s.client.NewRequest("PUT", apiEndpoint, record)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
err = option(req)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
responseRecord := new(WorklogRecord)
|
||||
resp, err := s.client.Do(req, responseRecord)
|
||||
if err != nil {
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
|
||||
return responseRecord, resp, nil
|
||||
}
|
||||
|
||||
// AddLink adds a link between two issues.
|
||||
//
|
||||
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/issueLink
|
||||
|
@ -272,6 +272,28 @@ func TestIssueService_AddWorklogRecord(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_UpdateWorklogRecord(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10000/worklog/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "PUT")
|
||||
testRequestURL(t, r, "/rest/api/2/issue/10000/worklog/1")
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/issue/10000/worklog/1","author":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"updateAuthor":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"comment":"I did some work here.","updated":"2018-02-14T22:14:46.003+0000","visibility":{"type":"group","value":"jira-developers"},"started":"2018-02-14T22:14:46.003+0000","timeSpent":"3h 20m","timeSpentSeconds":12000,"id":"100028","issueId":"10002"}`)
|
||||
})
|
||||
r := &WorklogRecord{
|
||||
TimeSpent: "1h",
|
||||
}
|
||||
record, _, err := testClient.Issue.UpdateWorklogRecord("10000", "1", r)
|
||||
if record == nil {
|
||||
t.Error("Expected Record. Record is nil")
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_AddLink(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
Loading…
x
Reference in New Issue
Block a user