summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-11-12 22:36:47 +0800
committerGitHub <noreply@github.com>2021-11-12 22:36:47 +0800
commitdf64fa486555de6f403a795fd16c2e9e1d59e535 (patch)
treeb899e9b9e5d57409b1bf0e3afbd606b6a3900235 /contrib
parent7f802631c54d2e91301158380b273b872d62bd80 (diff)
downloadgitea-df64fa486555de6f403a795fd16c2e9e1d59e535.tar.gz
gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.zip
Decouple unit test code from business code (#17623)
Diffstat (limited to 'contrib')
-rw-r--r--contrib/fixtures/fixture_generation.go6
-rw-r--r--contrib/pr/checkout.go7
2 files changed, 7 insertions, 6 deletions
diff --git a/contrib/fixtures/fixture_generation.go b/contrib/fixtures/fixture_generation.go
index 5e7dd39a78..74996a1f35 100644
--- a/contrib/fixtures/fixture_generation.go
+++ b/contrib/fixtures/fixture_generation.go
@@ -10,7 +10,7 @@ import (
"path/filepath"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
)
// To generate derivative fixtures, execute the following from Gitea's repository base dir:
@@ -31,13 +31,13 @@ var (
func main() {
pathToGiteaRoot := "."
fixturesDir = filepath.Join(pathToGiteaRoot, "models", "fixtures")
- if err := db.CreateTestEngine(db.FixturesOptions{
+ if err := unittest.CreateTestEngine(unittest.FixturesOptions{
Dir: fixturesDir,
}); err != nil {
fmt.Printf("CreateTestEngine: %+v", err)
os.Exit(1)
}
- if err := db.PrepareTestDatabase(); err != nil {
+ if err := unittest.PrepareTestDatabase(); err != nil {
fmt.Printf("PrepareTestDatabase: %+v\n", err)
os.Exit(1)
}
diff --git a/contrib/pr/checkout.go b/contrib/pr/checkout.go
index 89d92c8526..1e2a9714e3 100644
--- a/contrib/pr/checkout.go
+++ b/contrib/pr/checkout.go
@@ -26,6 +26,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
gitea_git "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/external"
@@ -99,8 +100,8 @@ func runPR() {
})
db.HasEngine = true
//x.ShowSQL(true)
- err = db.InitFixtures(
- db.FixturesOptions{
+ err = unittest.InitFixtures(
+ unittest.FixturesOptions{
Dir: path.Join(curDir, "models/fixtures/"),
},
)
@@ -108,7 +109,7 @@ func runPR() {
fmt.Printf("Error initializing test database: %v\n", err)
os.Exit(1)
}
- db.LoadFixtures()
+ unittest.LoadFixtures()
util.RemoveAll(setting.RepoRootPath)
util.RemoveAll(models.LocalCopyPath())
util.CopyDir(path.Join(curDir, "integrations/gitea-repositories-meta"), setting.RepoRootPath)