1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-02-11 13:38:57 +02:00

feat: Implement issue link type GET

This commit is contained in:
Johan Meiring 2019-10-13 19:11:10 +02:00 committed by Wes McNamee
parent 261889adc6
commit 57538b926c
2 changed files with 38 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package jira
import "fmt"
// IssueLinkTypeService handles issue link types for the JIRA instance / API.
//
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-group-Issue-link-types
@ -24,3 +26,21 @@ func (s *IssueLinkTypeService) GetList() ([]IssueLinkType, *Response, error) {
}
return linkTypeList, resp, nil
}
// Get gets info of a specific issue link type from JIRA.
//
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issueLinkType-issueLinkTypeId-get
func (s *IssueLinkTypeService) Get(ID string) (*IssueLinkType, *Response, error) {
apiEndPoint := fmt.Sprintf("rest/api/2/issueLinkType/%s", ID)
req, err := s.client.NewRequest("GET", apiEndPoint, nil)
if err != nil {
return nil, nil, err
}
linkType := new(IssueLinkType)
resp, err := s.client.Do(req, linkType)
if err != nil {
return nil, resp, NewJiraError(resp, err)
}
return linkType, resp, nil
}

View File

@ -30,3 +30,21 @@ func TestIssueLinkTypeService_GetList(t *testing.T) {
t.Errorf("Error give: %s", err)
}
}
func TestIssueLinkTypeService_Get(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/rest/api/2/issueLinkType/123", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testRequestURL(t, r, "/rest/api/2/issueLinkType/123")
fmt.Fprint(w, `{"id": "123","name": "Blocked","inward": "Blocked","outward": "Blocked",
"self": "https://www.example.com/jira/rest/api/2/issueLinkType/123"}`)
})
if linkType, _, err := testClient.IssueLinkType.Get("123"); err != nil {
t.Errorf("Error given: %s", err)
} else if linkType == nil {
t.Error("Expected linkType. LinkType is nil")
}
}