Skip to content

Commit

Permalink
Fix /api/repo/search integration tests (#2550)
Browse files Browse the repository at this point in the history
  • Loading branch information
Morlinest authored and lafriks committed Sep 20, 2017
1 parent 7a02978 commit 80b430d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions integrations/api_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package integrations

import (
"net/http"
"strings"
"testing"

"code.gitea.io/gitea/models"
Expand All @@ -33,22 +32,19 @@ func TestAPIUserReposNotLogin(t *testing.T) {
}
}

type searchResponseBody struct {
ok bool
data []api.Repository
}

func TestAPISearchRepoNotLogin(t *testing.T) {
prepareTestEnv(t)
const keyword = "test"

req := NewRequestf(t, "GET", "/api/v1/repos/search?q=%s", keyword)
resp := MakeRequest(t, req, http.StatusOK)

var body searchResponseBody
var body api.SearchResults
DecodeJSON(t, resp, &body)
for _, repo := range body.data {
assert.True(t, strings.Contains(repo.Name, keyword))
assert.NotEmpty(t, body.Data)
for _, repo := range body.Data {
assert.Contains(t, repo.Name, keyword)
assert.False(t, repo.Private)
}
}

Expand Down

0 comments on commit 80b430d

Please sign in to comment.