1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-28 08:39:03 +02:00

feat: Implement issue link type PUT

This commit is contained in:
Johan Meiring 2019-10-18 08:51:15 +02:00 committed by Wes McNamee
parent 75b9df8b01
commit 48a15c1044
2 changed files with 41 additions and 0 deletions

View File

@ -78,3 +78,20 @@ func (s *IssueLinkTypeService) Create(linkType *IssueLinkType) (*IssueLinkType,
}
return linkType, resp, nil
}
// Update updates an issue link type. The issue is found by key.
//
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issueLinkType-issueLinkTypeId-put
func (s *IssueLinkTypeService) Update(linkType *IssueLinkType) (*IssueLinkType, *Response, error) {
apiEndpoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", linkType.ID)
req, err := s.client.NewRequest("PUT", apiEndpoint, linkType)
if err != nil {
return nil, nil, err
}
resp, err := s.client.Do(req, nil)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
ret := *linkType
return &ret, resp, nil
}

View File

@ -73,3 +73,27 @@ func TestIssueLinkTypeService_Create(t *testing.T) {
t.Error("Expected linkType. LinkType is nil")
}
}
func TestIssueLinkTypeService_Update(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/rest/api/2/issueLinkType/100", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testRequestURL(t, r, "/rest/api/2/issueLinkType/100")
w.WriteHeader(http.StatusNoContent)
})
lt := &IssueLinkType{
ID: "100",
Name: "Problem/Incident",
Inward: "is caused by",
Outward: "causes",
}
if linkType, _, err := testClient.IssueLinkType.Update(lt); err != nil {
t.Errorf("Error given: %s", err)
} else if linkType == nil {
t.Error("Expected linkType. LinkType is nil")
}
}