-
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add IssueLinkTypeService with GetList and test
- Loading branch information
1 parent
40a1df2
commit 261889a
Showing
5 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package jira | ||
|
||
// 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 | ||
type IssueLinkTypeService struct { | ||
client *Client | ||
} | ||
|
||
// GetList gets all of the issue link types from JIRA. | ||
// | ||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issueLinkType-get | ||
func (s *IssueLinkTypeService) GetList() ([]IssueLinkType, *Response, error) { | ||
apiEndpoint := "rest/api/2/issueLinkType" | ||
req, err := s.client.NewRequest("GET", apiEndpoint, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
linkTypeList := []IssueLinkType{} | ||
resp, err := s.client.Do(req, &linkTypeList) | ||
if err != nil { | ||
return nil, resp, NewJiraError(resp, err) | ||
} | ||
return linkTypeList, resp, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package jira | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestIssueLinkTypeService_GetList(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
testAPIEndpoint := "/rest/api/2/issueLinkType" | ||
|
||
raw, err := ioutil.ReadFile("./mocks/all_issuelinktypes.json") | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "GET") | ||
testRequestURL(t, r, testAPIEndpoint) | ||
fmt.Fprint(w, string(raw)) | ||
}) | ||
|
||
linkTypes, _, err := testClient.IssueLinkType.GetList() | ||
if linkTypes == nil { | ||
t.Error("Expected issueLinkType list. LinkTypes is nil") | ||
} | ||
if err != nil { | ||
t.Errorf("Error give: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
[ | ||
{ | ||
"id": "12310361", | ||
"name": "Blocked", | ||
"inward": "Blocked", | ||
"outward": "Blocked", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310361" | ||
}, | ||
{ | ||
"id": "10032", | ||
"name": "Blocker", | ||
"inward": "is blocked by", | ||
"outward": "blocks", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10032" | ||
}, | ||
{ | ||
"id": "12310460", | ||
"name": "Child-Issue", | ||
"inward": "is a child of", | ||
"outward": "is a parent of", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310460" | ||
}, | ||
{ | ||
"id": "10020", | ||
"name": "Cloners", | ||
"inward": "is cloned by", | ||
"outward": "is a clone of", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10020" | ||
}, | ||
{ | ||
"id": "12310060", | ||
"name": "Container", | ||
"inward": "Is contained by", | ||
"outward": "contains", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310060" | ||
}, | ||
{ | ||
"id": "12310461", | ||
"name": "Dependency", | ||
"inward": "Dependency", | ||
"outward": "Dependency", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310461" | ||
}, | ||
{ | ||
"id": "12310360", | ||
"name": "Dependent", | ||
"inward": "Dependent", | ||
"outward": "Dependent", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310360" | ||
}, | ||
{ | ||
"id": "12310000", | ||
"name": "Duplicate", | ||
"inward": "is duplicated by", | ||
"outward": "duplicates", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310000" | ||
}, | ||
{ | ||
"id": "12310010", | ||
"name": "Incorporates", | ||
"inward": "is part of", | ||
"outward": "incorporates", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310010" | ||
}, | ||
{ | ||
"id": "12310462", | ||
"name": "Parent Feature", | ||
"inward": "Parent Feature", | ||
"outward": "Parent Feature", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310462" | ||
}, | ||
{ | ||
"id": "12310560", | ||
"name": "Problem/Incident", | ||
"inward": "is caused by", | ||
"outward": "causes", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310560" | ||
}, | ||
{ | ||
"id": "10030", | ||
"name": "Reference", | ||
"inward": "is related to", | ||
"outward": "relates to", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10030" | ||
}, | ||
{ | ||
"id": "12310050", | ||
"name": "Regression", | ||
"inward": "is broken by", | ||
"outward": "breaks", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310050" | ||
}, | ||
{ | ||
"id": "12310260", | ||
"name": "Related", | ||
"inward": "is related to", | ||
"outward": "relates to", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310260" | ||
}, | ||
{ | ||
"id": "12310040", | ||
"name": "Required", | ||
"inward": "is required by", | ||
"outward": "requires", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310040" | ||
}, | ||
{ | ||
"id": "12310051", | ||
"name": "Supercedes", | ||
"inward": "is superceded by", | ||
"outward": "supercedes", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/12310051" | ||
}, | ||
{ | ||
"id": "10001", | ||
"name": "dependent", | ||
"inward": "is depended upon by", | ||
"outward": "depends upon", | ||
"self": "https://issues.apache.org/jira/rest/api/2/issueLinkType/10001" | ||
} | ||
] |