1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Decouple unit test, remove intermediate unittestbridge package (#17662)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
wxiaoguang
2021-11-16 16:53:21 +08:00
committed by GitHub
parent 23bd7b1211
commit 81926d61db
151 changed files with 1719 additions and 1781 deletions

View File

@@ -19,7 +19,7 @@ func TestLookupRepoRedirect(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, 1, repoID)
_, err = LookupRepoRedirect(db.NonexistentID, "doesnotexist")
_, err = LookupRepoRedirect(unittest.NonexistentID, "doesnotexist")
assert.True(t, IsErrRepoRedirectNotExist(err))
}
@@ -27,15 +27,15 @@ func TestNewRepoRedirect(t *testing.T) {
// redirect to a completely new name
assert.NoError(t, unittest.PrepareTestDatabase())
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
assert.NoError(t, newRepoRedirect(db.GetEngine(db.DefaultContext), repo.OwnerID, repo.ID, repo.Name, "newreponame"))
db.AssertExistsAndLoadBean(t, &RepoRedirect{
unittest.AssertExistsAndLoadBean(t, &RepoRedirect{
OwnerID: repo.OwnerID,
LowerName: repo.LowerName,
RedirectRepoID: repo.ID,
})
db.AssertExistsAndLoadBean(t, &RepoRedirect{
unittest.AssertExistsAndLoadBean(t, &RepoRedirect{
OwnerID: repo.OwnerID,
LowerName: "oldrepo1",
RedirectRepoID: repo.ID,
@@ -46,15 +46,15 @@ func TestNewRepoRedirect2(t *testing.T) {
// redirect to previously used name
assert.NoError(t, unittest.PrepareTestDatabase())
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
assert.NoError(t, newRepoRedirect(db.GetEngine(db.DefaultContext), repo.OwnerID, repo.ID, repo.Name, "oldrepo1"))
db.AssertExistsAndLoadBean(t, &RepoRedirect{
unittest.AssertExistsAndLoadBean(t, &RepoRedirect{
OwnerID: repo.OwnerID,
LowerName: repo.LowerName,
RedirectRepoID: repo.ID,
})
db.AssertNotExistsBean(t, &RepoRedirect{
unittest.AssertNotExistsBean(t, &RepoRedirect{
OwnerID: repo.OwnerID,
LowerName: "oldrepo1",
RedirectRepoID: repo.ID,
@@ -65,10 +65,10 @@ func TestNewRepoRedirect3(t *testing.T) {
// redirect for a previously-unredirected repo
assert.NoError(t, unittest.PrepareTestDatabase())
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
repo := unittest.AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
assert.NoError(t, newRepoRedirect(db.GetEngine(db.DefaultContext), repo.OwnerID, repo.ID, repo.Name, "newreponame"))
db.AssertExistsAndLoadBean(t, &RepoRedirect{
unittest.AssertExistsAndLoadBean(t, &RepoRedirect{
OwnerID: repo.OwnerID,
LowerName: repo.LowerName,
RedirectRepoID: repo.ID,