upd(sam tests): use namsral flag
This commit is contained in:
@@ -1,24 +1,32 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/namsral/flag"
|
||||
"github.com/joho/godotenv"
|
||||
_ "github.com/joho/godotenv"
|
||||
"github.com/titpetric/factory"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// @todo this is a very optimistic initialization, make it more robust
|
||||
godotenv.Load("../../.env")
|
||||
|
||||
prefix := "sam"
|
||||
dsn := ""
|
||||
|
||||
p := func(s string) string {
|
||||
return prefix + "-" + s
|
||||
}
|
||||
|
||||
flag.StringVar(&dsn, p("db-dsn"), "crust:crust@tcp(db1:3306)/crust?collation=utf8mb4_general_ci", "DSN for database connection")
|
||||
flag.Parse()
|
||||
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
|
||||
// @todo this is a very optimistic initialization, make it more robust
|
||||
godotenv.Load("../../.env")
|
||||
factory.Database.Add("default", os.Getenv("SAM_DB_DSN"))
|
||||
factory.Database.Add("default", dsn)
|
||||
factory.Database.MustGet().Profiler = &factory.Database.ProfilerStdout
|
||||
|
||||
os.Exit(m.Run())
|
||||
|
||||
Reference in New Issue
Block a user