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