mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-01-22 03:10:10 +02:00
feat(filter): Add GetFavouriteList to FilterService.
This commit is contained in:
parent
bf2008dbbf
commit
645898e850
16
filter.go
16
filter.go
@ -59,6 +59,22 @@ func (fs *FilterService) GetList() ([]*Filter, *Response, error) {
|
||||
return filters, resp, err
|
||||
}
|
||||
|
||||
// GetFavouriteList retrieves the user's favourited filters from Jira
|
||||
func (fs *FilterService) GetFavouriteList() ([]*Filter, *Response, error) {
|
||||
apiEndpoint := "rest/api/2/filter/favourite"
|
||||
req, err := fs.client.NewRequest("GET", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
filters := []*Filter{}
|
||||
resp, err := fs.client.Do(req, &filters)
|
||||
if err != nil {
|
||||
jerr := NewJiraError(resp, err)
|
||||
return nil, resp, jerr
|
||||
}
|
||||
return filters, resp, err
|
||||
}
|
||||
|
||||
// Get retrieves a single Filter from Jira
|
||||
func (fs *FilterService) Get(filterID int) (*Filter, *Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("rest/api/2/filter/%d", filterID)
|
||||
|
@ -52,5 +52,27 @@ func TestFilterService_Get(t *testing.T) {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func TestFilterService_GetFavouriteList(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testAPIEdpoint := "/rest/api/2/filter/favourite"
|
||||
raw, err := ioutil.ReadFile("./mocks/favourite_filters.json")
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
testMux.HandleFunc(testAPIEdpoint, func(writer http.ResponseWriter, request *http.Request) {
|
||||
testMethod(t, request, "GET")
|
||||
testRequestURL(t, request, testAPIEdpoint)
|
||||
fmt.Fprint(writer, string(raw))
|
||||
})
|
||||
|
||||
filters, _, err := testClient.Filter.GetFavouriteList()
|
||||
if filters == nil {
|
||||
t.Error("Expected Filters list. Filters list is nil")
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
35
mocks/favourite_filters.json
Normal file
35
mocks/favourite_filters.json
Normal file
@ -0,0 +1,35 @@
|
||||
[
|
||||
{
|
||||
"self": "http://your-domain.atlassian.net/rest/api/2/filter/10000",
|
||||
"id": "10000",
|
||||
"name": "All Open Bugs",
|
||||
"description": "Lists all open bugs",
|
||||
"owner": {
|
||||
"self": "http://your-domain.atlassian.net/rest/api/2/user?username=mia",
|
||||
"key": "mia",
|
||||
"accountId": "99:27935d01-92a7-4687-8272-a9b8d3b2ae2e",
|
||||
"name": "mia",
|
||||
"avatarUrls": {
|
||||
"48x48": "http://your-domain.atlassian.net/secure/useravatar?size=large&ownerId=mia",
|
||||
"24x24": "http://your-domain.atlassian.net/secure/useravatar?size=small&ownerId=mia",
|
||||
"16x16": "http://your-domain.atlassian.net/secure/useravatar?size=xsmall&ownerId=mia",
|
||||
"32x32": "http://your-domain.atlassian.net/secure/useravatar?size=medium&ownerId=mia"
|
||||
},
|
||||
"displayName": "Mia Krystof",
|
||||
"active": false
|
||||
},
|
||||
"jql": "type = Bug and resolution is empty",
|
||||
"viewUrl": "http://your-domain.atlassian.net/issues/?filter=10000",
|
||||
"searchUrl": "http://your-domain.atlassian.net/rest/api/2/search?jql=type%20%3D%20Bug%20and%20resolutino%20is%20empty",
|
||||
"favourite": true,
|
||||
"favouritedCount": 0,
|
||||
"sharePermissions": [],
|
||||
"subscriptions": {
|
||||
"size": 0,
|
||||
"items": [],
|
||||
"max-results": 0,
|
||||
"start-index": 0,
|
||||
"end-index": 0
|
||||
}
|
||||
}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user