0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-28 04:08:25 +01:00

Improve testing for pgsql empty repository (#22223)

This commit is contained in:
Lunny Xiao 2022-12-24 02:34:51 +08:00 committed by GitHub
parent 2cf0cf0de1
commit 2b0b56319e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,8 @@ import (
"code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/tests" "code.gitea.io/gitea/tests"
"github.com/stretchr/testify/assert"
) )
func TestEmptyRepo(t *testing.T) { func TestEmptyRepo(t *testing.T) {
@ -21,7 +23,8 @@ func TestEmptyRepo(t *testing.T) {
"commit/1ae57b34ccf7e18373", "commit/1ae57b34ccf7e18373",
"graph", "graph",
} }
emptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{}, unittest.Cond("is_empty = ?", true)) emptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 5})
assert.True(t, emptyRepo.IsEmpty)
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: emptyRepo.OwnerID}) owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: emptyRepo.OwnerID})
for _, subpath := range subpaths { for _, subpath := range subpaths {
req := NewRequestf(t, "GET", "/%s/%s/%s", owner.Name, emptyRepo.Name, subpath) req := NewRequestf(t, "GET", "/%s/%s/%s", owner.Name, emptyRepo.Name, subpath)