-
-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from Thiht/master
feat: Add ResolutionService to retrieve resolutions
- Loading branch information
Showing
11 changed files
with
328 additions
and
25 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
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
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,140 @@ | ||
[ | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/1", | ||
"id": "1", | ||
"description": "A fix for this issue is checked into the tree and tested.", | ||
"name": "Fixed" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/2", | ||
"id": "2", | ||
"description": "The problem described is an issue which will never be fixed.", | ||
"name": "Won't Fix" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/3", | ||
"id": "3", | ||
"description": "The problem is a duplicate of an existing issue.", | ||
"name": "Duplicate" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/6", | ||
"id": "6", | ||
"description": "The problem isn't valid and it can't be fixed.", | ||
"name": "Invalid" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/4", | ||
"id": "4", | ||
"description": "The problem is not completely described.", | ||
"name": "Incomplete" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/5", | ||
"id": "5", | ||
"description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", | ||
"name": "Cannot Reproduce" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/7", | ||
"id": "7", | ||
"description": "Later", | ||
"name": "Later" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/8", | ||
"id": "8", | ||
"description": "The described issue is not actually a problem - it is as designed.", | ||
"name": "Not A Problem" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/9", | ||
"id": "9", | ||
"description": "Unresolved", | ||
"name": "Unresolved" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10", | ||
"id": "10", | ||
"description": "As the name suggests", | ||
"name": "Implemented" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/11", | ||
"id": "11", | ||
"description": "", | ||
"name": "Done" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10000", | ||
"id": "10000", | ||
"description": "This issue was automatically closed", | ||
"name": "Auto Closed" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10001", | ||
"id": "10001", | ||
"description": "", | ||
"name": "Pending Closed" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10002", | ||
"id": "10002", | ||
"description": "REMIND", | ||
"name": "REMIND" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10003", | ||
"id": "10003", | ||
"description": "Resolved", | ||
"name": "Resolved" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10004", | ||
"id": "10004", | ||
"description": "Not A Bug", | ||
"name": "Not A Bug" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10005", | ||
"id": "10005", | ||
"description": "Workaround", | ||
"name": "Workaround" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10006", | ||
"id": "10006", | ||
"description": "Staged", | ||
"name": "Staged" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10007", | ||
"id": "10007", | ||
"description": "Delivered", | ||
"name": "Delivered" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10008", | ||
"id": "10008", | ||
"description": "Information Provided", | ||
"name": "Information Provided" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10009", | ||
"id": "10009", | ||
"description": "Works for Me", | ||
"name": "Works for Me" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10010", | ||
"id": "10010", | ||
"description": "Feedback Received", | ||
"name": "Feedback Received" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/resolution/10011", | ||
"id": "10011", | ||
"description": "Won't Do", | ||
"name": "Won't Do" | ||
} | ||
] |
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,30 @@ | ||
[ | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/statuscategory/1", | ||
"id": 1, | ||
"key": "undefined", | ||
"colorName": "medium-gray", | ||
"name": "No Category" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/statuscategory/2", | ||
"id": 2, | ||
"key": "new", | ||
"colorName": "blue-gray", | ||
"name": "To Do" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/statuscategory/4", | ||
"id": 4, | ||
"key": "indeterminate", | ||
"colorName": "yellow", | ||
"name": "In Progress" | ||
}, | ||
{ | ||
"self": "https://issues.apache.org/jira/rest/api/2/statuscategory/3", | ||
"id": 3, | ||
"key": "done", | ||
"colorName": "green", | ||
"name": "Done" | ||
} | ||
] |
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,35 @@ | ||
package jira | ||
|
||
// ResolutionService handles resolutions for the JIRA instance / API. | ||
// | ||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Resolution | ||
type ResolutionService struct { | ||
client *Client | ||
} | ||
|
||
// Resolution represents a resolution of a JIRA issue. | ||
// Typical types are "Fixed", "Suspended", "Won't Fix", ... | ||
type Resolution struct { | ||
Self string `json:"self" structs:"self"` | ||
ID string `json:"id" structs:"id"` | ||
Description string `json:"description" structs:"description"` | ||
Name string `json:"name" structs:"name"` | ||
} | ||
|
||
// GetList gets all resolutions from JIRA | ||
// | ||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-resolution-get | ||
func (s *ResolutionService) GetList() ([]Resolution, *Response, error) { | ||
apiEndpoint := "rest/api/2/resolution" | ||
req, err := s.client.NewRequest("GET", apiEndpoint, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
resolutionList := []Resolution{} | ||
resp, err := s.client.Do(req, &resolutionList) | ||
if err != nil { | ||
return nil, resp, NewJiraError(resp, err) | ||
} | ||
return resolutionList, 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 TestResolutionService_GetList(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
testAPIEdpoint := "/rest/api/2/resolution" | ||
|
||
raw, err := ioutil.ReadFile("./mocks/all_resolutions.json") | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "GET") | ||
testRequestURL(t, r, testAPIEdpoint) | ||
fmt.Fprint(w, string(raw)) | ||
}) | ||
|
||
resolution, _, err := testClient.Resolution.GetList() | ||
if resolution == nil { | ||
t.Error("Expected resolution list. Resolution list is nil") | ||
} | ||
if err != nil { | ||
t.Errorf("Error given: %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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package jira | ||
|
||
// StatusCategoryService handles status categories for the JIRA instance / API. | ||
// | ||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-Statuscategory | ||
type StatusCategoryService struct { | ||
client *Client | ||
} | ||
|
||
// StatusCategory represents the category a status belongs to. | ||
// Those categories can be user defined in every JIRA instance. | ||
type StatusCategory struct { | ||
Self string `json:"self" structs:"self"` | ||
ID int `json:"id" structs:"id"` | ||
Name string `json:"name" structs:"name"` | ||
Key string `json:"key" structs:"key"` | ||
ColorName string `json:"colorName" structs:"colorName"` | ||
} | ||
|
||
// These constants are the keys of the default JIRA status categories | ||
const ( | ||
StatusCategoryComplete = "done" | ||
StatusCategoryInProgress = "indeterminate" | ||
StatusCategoryToDo = "new" | ||
StatusCategoryUndefined = "undefined" | ||
) | ||
|
||
// GetList gets all status categories from JIRA | ||
// | ||
// JIRA API docs: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-statuscategory-get | ||
func (s *StatusCategoryService) GetList() ([]StatusCategory, *Response, error) { | ||
apiEndpoint := "rest/api/2/statuscategory" | ||
req, err := s.client.NewRequest("GET", apiEndpoint, nil) | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
statusCategoryList := []StatusCategory{} | ||
resp, err := s.client.Do(req, &statusCategoryList) | ||
if err != nil { | ||
return nil, resp, NewJiraError(resp, err) | ||
} | ||
return statusCategoryList, resp, nil | ||
} |
Oops, something went wrong.