Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require.NotEmpty ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkcsoft I don't want to stop tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Morlinest Why? One failing test is enough to let whole integration tests fail. It will speed up testing a lot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daviian If you are thinking about that like this, we should use require.* everywhere :). I want to see more than 1 step ahead. In my opinion, it's like parsing a form and showing just first error to user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Morlinest in this particular test every following assertion will evaluate to false so there is no reason to check them anyway

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daviian Following assertions are inside range loop.

for _, repo := range body.Data {
assert.Contains(t, repo.Name, keyword)
assert.False(t, repo.Private)
}
}

Expand Down