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:
parent
c2f232c130
commit
a6cca9eec1
2 changed files with 8 additions and 0 deletions
|
@ -30,6 +30,7 @@ type ListMilestoneOption struct {
|
||||||
ListOptions
|
ListOptions
|
||||||
// open, closed, all
|
// open, closed, all
|
||||||
State StateType
|
State StateType
|
||||||
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryEncode turns options into querystring argument
|
// QueryEncode turns options into querystring argument
|
||||||
|
@ -38,6 +39,9 @@ func (opt *ListMilestoneOption) QueryEncode() string {
|
||||||
if opt.State != "" {
|
if opt.State != "" {
|
||||||
query.Add("state", string(opt.State))
|
query.Add("state", string(opt.State))
|
||||||
}
|
}
|
||||||
|
if len(opt.Name) != 0 {
|
||||||
|
query.Add("name", opt.Name)
|
||||||
|
}
|
||||||
return query.Encode()
|
return query.Encode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,10 @@ func TestMilestones(t *testing.T) {
|
||||||
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: StateAll})
|
ml, err = c.ListRepoMilestones(repo.Owner.UserName, repo.Name, ListMilestoneOption{State: StateAll})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, ml, 3)
|
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
|
// GetMilestone
|
||||||
_, err = c.GetMilestone(repo.Owner.UserName, repo.Name, m4.ID)
|
_, err = c.GetMilestone(repo.Owner.UserName, repo.Name, m4.ID)
|
||||||
|
|
Loading…
Reference in a new issue