summaryrefslogtreecommitdiffstats
path: root/models/unit_tests.go
diff options
context:
space:
mode:
authorguillep2k <18600385+guillep2k@users.noreply.github.com>2020-02-15 05:59:43 -0300
committerGitHub <noreply@github.com>2020-02-15 10:59:43 +0200
commit7e920703f94c4f2782860a72cc6beca5671736f5 (patch)
treebbc652b204f28e7d8b2cff22eed44c021ae684cf /models/unit_tests.go
parent62a1322cf9940daa987ca16053f5081d7da54298 (diff)
downloadgitea-7e920703f94c4f2782860a72cc6beca5671736f5.tar.gz
gitea-7e920703f94c4f2782860a72cc6beca5671736f5.zip
Move fixture generation to contrib and add test (#10277)
* Add fixture gen tool and fix "access" test * Close file before exiting * Add missing repo_unit for repo id: 5 * Fix count on TestAPIOrgRepos * Generate access fixture from contrib and add test * Remove old access fixture generation * Fix lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/unit_tests.go')
-rw-r--r--models/unit_tests.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/models/unit_tests.go b/models/unit_tests.go
index eb4da37fe5..b9f894af7c 100644
--- a/models/unit_tests.go
+++ b/models/unit_tests.go
@@ -28,7 +28,10 @@ import (
const NonexistentID = int64(math.MaxInt64)
// giteaRoot a path to the gitea root
-var giteaRoot string
+var (
+ giteaRoot string
+ fixturesDir string
+)
func fatalTestError(fmtStr string, args ...interface{}) {
fmt.Fprintf(os.Stderr, fmtStr, args...)
@@ -40,8 +43,8 @@ func fatalTestError(fmtStr string, args ...interface{}) {
func MainTest(m *testing.M, pathToGiteaRoot string) {
var err error
giteaRoot = pathToGiteaRoot
- fixturesDir := filepath.Join(pathToGiteaRoot, "models", "fixtures")
- if err = createTestEngine(fixturesDir); err != nil {
+ fixturesDir = filepath.Join(pathToGiteaRoot, "models", "fixtures")
+ if err = CreateTestEngine(fixturesDir); err != nil {
fatalTestError("Error creating test engine: %v\n", err)
}
@@ -82,7 +85,8 @@ func MainTest(m *testing.M, pathToGiteaRoot string) {
os.Exit(exitStatus)
}
-func createTestEngine(fixturesDir string) error {
+// CreateTestEngine creates a memory database and loads the fixture data from fixturesDir
+func CreateTestEngine(fixturesDir string) error {
var err error
x, err = xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
if err != nil {