ListIssues: add milestones filter #327
@@ -56,10 +56,11 @@ type Issue struct { | ||||
// ListIssueOption list issue options | ||||
type ListIssueOption struct { | ||||
ListOptions | ||||
State StateType | ||||
Type IssueType | ||||
Labels []string | ||||
KeyWord string | ||||
State StateType | ||||
Type IssueType | ||||
Labels []string | ||||
Milestones []string | ||||
KeyWord string | ||||
} | ||||
| ||||
// StateType issue state type | ||||
@@ -89,24 +90,25 @@ const ( | ||||
// QueryEncode turns options into querystring argument | ||||
func (opt *ListIssueOption) QueryEncode() string { | ||||
query := opt.getURLQuery() | ||||
| ||||
if len(opt.State) > 0 { | ||||
query.Add("state", string(opt.State)) | ||||
} | ||||
| ||||
if len(opt.Labels) > 0 { | ||||
var lq string | ||||
for _, l := range opt.Labels { | ||||
if len(lq) > 0 { | ||||
lq += "," | ||||
} | ||||
lq += l | ||||
} | ||||
query.Add("labels", lq) | ||||
query.Add("labels", strings.Join(opt.Labels, ",")) | ||||
} | ||||
| ||||
if len(opt.KeyWord) > 0 { | ||||
query.Add("q", opt.KeyWord) | ||||
} | ||||
6543 marked this conversation as resolved Outdated | ||||
| ||||
query.Add("type", string(opt.Type)) | ||||
| ||||
if len(opt.Milestones) > 0 { | ||||
query.Add("milestones", strings.Join(opt.Milestones, ",")) | ||||
} | ||||
| ||||
return query.Encode() | ||||
} | ||||
| ||||
|
@@ -71,12 +71,12 @@ func listIssues(t *testing.T, c *Client) { | ||||
log.Println("== TestListIssues ==") | ||||
| ||||
issues, err := c.ListRepoIssues("test01", "IssueTestsRepo", ListIssueOption{ | ||||
Labels: []string{"Label2"}, | ||||
Labels: []string{"Label1", "Label2"}, | ||||
KeyWord: "", | ||||
State: "all", | ||||
}) | ||||
assert.NoError(t, err) | ||||
assert.Len(t, issues, 2) | ||||
assert.Len(t, issues, 1) | ||||
| ||||
issues, err = c.ListIssues(ListIssueOption{ | ||||
Labels: []string{"Label2"}, | ||||
@@ -86,6 +86,18 @@ func listIssues(t *testing.T, c *Client) { | ||||
assert.NoError(t, err) | ||||
assert.Len(t, issues, 1) | ||||
| ||||
issues, err = c.ListRepoIssues("test01", "IssueTestsRepo", ListIssueOption{ | ||||
Milestones: []string{"mile1"}, | ||||
State: "all", | ||||
}) | ||||
assert.NoError(t, err) | ||||
assert.Len(t, issues, 3) | ||||
for i := range issues { | ||||
if assert.NotNil(t, issues[i].Milestone) { | ||||
assert.EqualValues(t, "mile1", issues[i].Milestone.Title) | ||||
} | ||||
} | ||||
| ||||
issues, err = c.ListRepoIssues("test01", "IssueTestsRepo", ListIssueOption{}) | ||||
assert.NoError(t, err) | ||||
assert.Len(t, issues, 3) | ||||
|
Reference in New Issue
Block a user
Why'd you change this?
as the the related commit message tell: code formateion
to make it similar to milestone ones
and I choose
for i := range objlist
overfor _, o := range objlist
because of speed thoughtsstrings.Join 🎉