Пример #1
0
func LoadEnv(loadDB bool) {
	godotenv.Load(Env)
	config.CheckEnv()

	if loadDB {
		db = config.NewDB()
	}
}
Пример #2
0
func SetupSpec() (db *gorm.DB) {
	godotenv.Load("../../.env.test")
	config.CheckEnv()
	db = config.NewDB()
	cmd.RegisterDb(db)

	cmd.RootCmd.SetArgs([]string{"db:empty", "--env=../../.env.test"})
	if err := cmd.RootCmd.Execute(); err != nil {
		panic(fmt.Sprintf("Unable to empty database %v", err))
	}

	cmd.RootCmd.SetArgs([]string{"db:migrate", "--env=../../.env.test"})
	if err := cmd.RootCmd.Execute(); err != nil {
		panic(fmt.Sprintf("Unable to migrate database %v", err))
	}

	models.New(db)
	return
}