mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Integration tests for issues API (#2059)
This commit is contained in:
parent
4c0e567062
commit
735676267e
2 changed files with 78 additions and 15 deletions
|
@ -18,27 +18,25 @@ import (
|
|||
|
||||
// ListIssues list the issues of a repository
|
||||
func ListIssues(ctx *context.APIContext) {
|
||||
isClosed := ctx.Query("state") == "closed"
|
||||
issueOpts := models.IssuesOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Page: ctx.QueryInt("page"),
|
||||
IsClosed: util.OptionalBoolOf(isClosed),
|
||||
var isClosed util.OptionalBool
|
||||
switch ctx.Query("state") {
|
||||
case "closed":
|
||||
isClosed = util.OptionalBoolTrue
|
||||
case "all":
|
||||
isClosed = util.OptionalBoolNone
|
||||
default:
|
||||
isClosed = util.OptionalBoolFalse
|
||||
}
|
||||
|
||||
issues, err := models.Issues(&issueOpts)
|
||||
issues, err := models.Issues(&models.IssuesOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Page: ctx.QueryInt("page"),
|
||||
IsClosed: isClosed,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.Error(500, "Issues", err)
|
||||
return
|
||||
}
|
||||
if ctx.Query("state") == "all" {
|
||||
issueOpts.IsClosed = util.OptionalBoolOf(!isClosed)
|
||||
tempIssues, err := models.Issues(&issueOpts)
|
||||
if err != nil {
|
||||
ctx.Error(500, "Issues", err)
|
||||
return
|
||||
}
|
||||
issues = append(issues, tempIssues...)
|
||||
}
|
||||
|
||||
err = models.IssueList(issues).LoadAttributes()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue