Fix /api/repo/search integration tests (#2550)
This commit is contained in:
parent
7a0297819d
commit
80b430d7c0
|
@ -6,7 +6,6 @@ package integrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
|
@ -33,11 +32,6 @@ func TestAPIUserReposNotLogin(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type searchResponseBody struct {
|
|
||||||
ok bool
|
|
||||||
data []api.Repository
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAPISearchRepoNotLogin(t *testing.T) {
|
func TestAPISearchRepoNotLogin(t *testing.T) {
|
||||||
prepareTestEnv(t)
|
prepareTestEnv(t)
|
||||||
const keyword = "test"
|
const keyword = "test"
|
||||||
|
@ -45,10 +39,12 @@ func TestAPISearchRepoNotLogin(t *testing.T) {
|
||||||
req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword)
|
req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword)
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
var body searchResponseBody
|
var body api.SearchResults
|
||||||
DecodeJSON(t, resp, &body)
|
DecodeJSON(t, resp, &body)
|
||||||
for _, repo := range body.data {
|
assert.NotEmpty(t, body.Data)
|
||||||
assert.True(t, strings.Contains(repo.Name, keyword))
|
for _, repo := range body.Data {
|
||||||
|
assert.Contains(t, repo.Name, keyword)
|
||||||
|
assert.False(t, repo.Private)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue