diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-11-12 22:36:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-12 22:36:47 +0800 |
commit | df64fa486555de6f403a795fd16c2e9e1d59e535 (patch) | |
tree | b899e9b9e5d57409b1bf0e3afbd606b6a3900235 /modules/repository | |
parent | 7f802631c54d2e91301158380b273b872d62bd80 (diff) | |
download | gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.tar.gz gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.zip |
Decouple unit test code from business code (#17623)
Diffstat (limited to 'modules/repository')
-rw-r--r-- | modules/repository/commits_test.go | 5 | ||||
-rw-r--r-- | modules/repository/create_test.go | 3 | ||||
-rw-r--r-- | modules/repository/fork_test.go | 3 | ||||
-rw-r--r-- | modules/repository/main_test.go | 4 |
4 files changed, 9 insertions, 6 deletions
diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go index c62ad58449..c47d9cf48c 100644 --- a/modules/repository/commits_test.go +++ b/modules/repository/commits_test.go @@ -12,12 +12,13 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" "github.com/stretchr/testify/assert" ) func TestPushCommits_ToAPIPayloadCommits(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) pushCommits := NewPushCommits() pushCommits.Commits = []*PushCommit{ @@ -100,7 +101,7 @@ func TestPushCommits_ToAPIPayloadCommits(t *testing.T) { } func TestPushCommits_AvatarLink(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) pushCommits := NewPushCommits() pushCommits.Commits = []*PushCommit{ diff --git a/modules/repository/create_test.go b/modules/repository/create_test.go index 040c061d92..d833017160 100644 --- a/modules/repository/create_test.go +++ b/modules/repository/create_test.go @@ -10,13 +10,14 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/structs" "github.com/stretchr/testify/assert" ) func TestIncludesAllRepositoriesTeams(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) testTeamRepositories := func(teamID int64, repoIds []int64) { team := db.AssertExistsAndLoadBean(t, &models.Team{ID: teamID}).(*models.Team) diff --git a/modules/repository/fork_test.go b/modules/repository/fork_test.go index 7a05f9dd97..bfb813adbc 100644 --- a/modules/repository/fork_test.go +++ b/modules/repository/fork_test.go @@ -9,11 +9,12 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "github.com/stretchr/testify/assert" ) func TestForkRepository(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) // user 13 has already forked repo10 user := db.AssertExistsAndLoadBean(t, &models.User{ID: 13}).(*models.User) diff --git a/modules/repository/main_test.go b/modules/repository/main_test.go index 91d0d36ca0..262d339481 100644 --- a/modules/repository/main_test.go +++ b/modules/repository/main_test.go @@ -8,9 +8,9 @@ import ( "path/filepath" "testing" - "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" ) func TestMain(m *testing.M) { - db.MainTest(m, filepath.Join("..", "..")) + unittest.MainTest(m, filepath.Join("..", "..")) } |