Fix URL param (#568)

The URL param for pre-releases was `draft`, it should be `pre-release`.

Co-authored-by: qwerty287 <ndev@web.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/568
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: qwerty287 <qwerty287@noreply.gitea.io>
Co-committed-by: qwerty287 <qwerty287@noreply.gitea.io>
This commit is contained in:
qwerty287 2022-02-15 23:14:18 +08:00 committed by 6543
parent 36c7f8c8de
commit 29e6eb37fe
2 changed files with 8 additions and 1 deletions

View file

@ -47,7 +47,7 @@ func (opt *ListReleasesOptions) QueryEncode() string {
query.Add("draft", fmt.Sprintf("%t", *opt.IsDraft))
}
if opt.IsPreRelease != nil {
query.Add("draft", fmt.Sprintf("%t", *opt.IsPreRelease))
query.Add("pre-release", fmt.Sprintf("%t", *opt.IsPreRelease))
}
return query.Encode()

View file

@ -51,6 +51,13 @@ func TestRelease(t *testing.T) {
r2, _, err = c.GetReleaseByTag(repo.Owner.UserName, repo.Name, r.TagName)
assert.NoError(t, err)
assert.EqualValues(t, r, r2)
// ListRelease without pre-releases
tr := true
rl, _, err = c.ListReleases(repo.Owner.UserName, repo.Name, ListReleasesOptions{
IsPreRelease: &tr,
})
assert.NoError(t, err)
assert.Len(t, rl, 0) // created release is a pre-release
// test fallback
r2, _, err = c.fallbackGetReleaseByTag(repo.Owner.UserName, repo.Name, r.TagName)
assert.NoError(t, err)