add(all): migrations for tests, statik update
This commit is contained in:
@@ -9,10 +9,11 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
_ "github.com/crusttech/crust/sam/db/mysql"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rakyll/statik/fs"
|
|
||||||
"github.com/titpetric/factory"
|
"github.com/titpetric/factory"
|
||||||
|
"github.com/titpetric/statik/fs"
|
||||||
|
|
||||||
|
"github.com/crusttech/crust/sam/db/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func statements(contents []byte, err error) ([]string, error) {
|
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 {
|
func Migrate(db *factory.DB) error {
|
||||||
statikFS, err := fs.New()
|
statikFS, err := fs.New(mysql.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Error creating statik filesystem")
|
return errors.Wrap(err, "Error creating statik filesystem")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/joho/godotenv"
|
"log"
|
||||||
"github.com/namsral/flag"
|
|
||||||
"github.com/titpetric/factory"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"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) {
|
func TestMain(m *testing.M) {
|
||||||
@@ -29,7 +34,19 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
factory.Database.Add("default", dsn)
|
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())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
_ "github.com/crusttech/crust/system/db/mysql"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rakyll/statik/fs"
|
|
||||||
"github.com/titpetric/factory"
|
"github.com/titpetric/factory"
|
||||||
|
"github.com/titpetric/statik/fs"
|
||||||
|
|
||||||
|
"github.com/crusttech/crust/system/db/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
func statements(contents []byte, err error) ([]string, error) {
|
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 {
|
func Migrate(db *factory.DB) error {
|
||||||
statikFS, err := fs.New()
|
statikFS, err := fs.New(mysql.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Error creating statik filesystem")
|
return errors.Wrap(err, "Error creating statik filesystem")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user