Update ListMilestoneOption struct (#393)

Update ListMilestoneOption struct

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/393
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
6543 2020-09-05 06:27:44 +00:00
parent c2f232c130
commit a6cca9eec1
2 changed files with 8 additions and 0 deletions

View File

@ -30,6 +30,7 @@ type ListMilestoneOption struct {
ListOptions
// open, closed, all
State StateType
Name string
}
// QueryEncode turns options into querystring argument
@ -38,6 +39,9 @@ func (opt *ListMilestoneOption) QueryEncode() string {
if opt.State != "" {
query.Add("state", string(opt.State))
}
if len(opt.Name) != 0 {
query.Add("name", opt.Name)
}
return query.Encode()
}

View File

@ -49,6 +49,10 @@ func TestMilestones(t *testing.T) {
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: StateAll})
assert.NoError(t, err)
assert.Len(t, ml, 3)
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: StateAll, Name: "V3.0"})
assert.NoError(t, err)
assert.Len(t, ml, 1)
assert.EqualValues(t, "v3.0", ml[0].Title)
// GetMilestone
_, err = c.GetMilestone(repo.Owner.UserName, repo.Name, m4.ID)