Fixed tests with sqlite
This commit is contained in:
parent
93745865cd
commit
60e983c529
|
@ -24,6 +24,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/testfixtures.v2"
|
"gopkg.in/testfixtures.v2"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -52,6 +53,7 @@ func MainTest(m *testing.M, pathToRoot string) {
|
||||||
func createTestEngine(fixturesDir string) error {
|
func createTestEngine(fixturesDir string) error {
|
||||||
var err error
|
var err error
|
||||||
var fixturesHelper testfixtures.Helper
|
var fixturesHelper testfixtures.Helper
|
||||||
|
fixturesHelper = &testfixtures.SQLite{}
|
||||||
// If set, use the config we provided instead of normal
|
// If set, use the config we provided instead of normal
|
||||||
if os.Getenv("VIKUNJA_TESTS_USE_CONFIG") == "1" {
|
if os.Getenv("VIKUNJA_TESTS_USE_CONFIG") == "1" {
|
||||||
config.InitConfig()
|
config.InitConfig()
|
||||||
|
@ -60,7 +62,14 @@ func createTestEngine(fixturesDir string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fixturesHelper = &testfixtures.MySQL{}
|
err = x.Sync2(GetTables()...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if viper.GetString("database.type") == "mysql" {
|
||||||
|
fixturesHelper = &testfixtures.MySQL{}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
x, err = xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
|
x, err = xorm.NewEngine("sqlite3", "file::memory:?cache=shared")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -78,8 +87,6 @@ func createTestEngine(fixturesDir string) error {
|
||||||
if os.Getenv("UNIT_TESTS_VERBOSE") == "1" {
|
if os.Getenv("UNIT_TESTS_VERBOSE") == "1" {
|
||||||
x.ShowSQL(true)
|
x.ShowSQL(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fixturesHelper = &testfixtures.SQLite{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitFixtures(fixturesHelper, fixturesDir)
|
return InitFixtures(fixturesHelper, fixturesDir)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user