add(all): migrations for tests, statik update
This commit is contained in:
parent
556a61b914
commit
297ffda5ad
@ -9,10 +9,11 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
_ "github.com/crusttech/crust/sam/db/mysql"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rakyll/statik/fs"
|
||||
"github.com/titpetric/factory"
|
||||
"github.com/titpetric/statik/fs"
|
||||
|
||||
"github.com/crusttech/crust/sam/db/mysql"
|
||||
)
|
||||
|
||||
func statements(contents []byte, err error) ([]string, error) {
|
||||
@ -23,7 +24,7 @@ func statements(contents []byte, err error) ([]string, error) {
|
||||
}
|
||||
|
||||
func Migrate(db *factory.DB) error {
|
||||
statikFS, err := fs.New()
|
||||
statikFS, err := fs.New(mysql.Data())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error creating statik filesystem")
|
||||
}
|
||||
|
||||
@ -2,12 +2,17 @@ package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/namsral/flag"
|
||||
"github.com/titpetric/factory"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/namsral/flag"
|
||||
"github.com/titpetric/factory"
|
||||
|
||||
samMigrate "github.com/crusttech/crust/sam/db"
|
||||
systemMigrate "github.com/crusttech/crust/system/db"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@ -29,7 +34,19 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
factory.Database.Add("default", dsn)
|
||||
factory.Database.MustGet().Profiler = &factory.Database.ProfilerStdout
|
||||
|
||||
db := factory.Database.MustGet()
|
||||
db.Profiler = &factory.Database.ProfilerStdout
|
||||
|
||||
// migrate database schema
|
||||
if err := systemMigrate.Migrate(db); err != nil {
|
||||
log.Printf("Error running migrations: %+v\n", err)
|
||||
return
|
||||
}
|
||||
if err := samMigrate.Migrate(db); err != nil {
|
||||
log.Printf("Error running migrations: %+v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
@ -9,10 +9,11 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
_ "github.com/crusttech/crust/system/db/mysql"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rakyll/statik/fs"
|
||||
"github.com/titpetric/factory"
|
||||
"github.com/titpetric/statik/fs"
|
||||
|
||||
"github.com/crusttech/crust/system/db/mysql"
|
||||
)
|
||||
|
||||
func statements(contents []byte, err error) ([]string, error) {
|
||||
@ -23,7 +24,7 @@ func statements(contents []byte, err error) ([]string, error) {
|
||||
}
|
||||
|
||||
func Migrate(db *factory.DB) error {
|
||||
statikFS, err := fs.New()
|
||||
statikFS, err := fs.New(mysql.Data())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error creating statik filesystem")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user