postgres-switch-for-tests #255
@ -15,7 +15,6 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/config"
|
||||
"git.grassecon.net/urdt/ussd/initializers"
|
||||
@ -28,14 +27,13 @@ import (
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla().WithDomain("AfricasTalking").WithContextKey("at-session-id")
|
||||
baseDir = testdataloader.GetBasePath()
|
||||
scriptDir = path.Join("services", "registration")
|
||||
build = "dev"
|
||||
menuSeparator = ": "
|
||||
)
|
||||
|
||||
func init() {
|
||||
initializers.LoadEnvVariables(baseDir)
|
||||
initializers.LoadEnvVariables()
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -44,8 +42,6 @@ func main() {
|
||||
var connStr string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var database string
|
||||
var dbSchema string
|
||||
var engineDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
@ -75,8 +71,6 @@ func main() {
|
||||
logg.Infof("start command", "build", build, "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "Database", database)
|
||||
ctx = context.WithValue(ctx, "Schema", dbSchema)
|
||||
ln, err := lang.LanguageFromCode(config.DefaultLanguage)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "default language set error: %v", err)
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/config"
|
||||
"git.grassecon.net/urdt/ussd/initializers"
|
||||
@ -25,13 +24,12 @@ import (
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
baseDir = testdataloader.GetBasePath()
|
||||
scriptDir = path.Join("services", "registration")
|
||||
menuSeparator = ": "
|
||||
)
|
||||
|
||||
func init() {
|
||||
initializers.LoadEnvVariables(baseDir)
|
||||
initializers.LoadEnvVariables()
|
||||
}
|
||||
|
||||
type asyncRequestParser struct {
|
||||
@ -54,8 +52,6 @@ func main() {
|
||||
var sessionId string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var database string
|
||||
var dbSchema string
|
||||
var engineDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
@ -86,8 +82,6 @@ func main() {
|
||||
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size, "sessionId", sessionId)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "Database", database)
|
||||
ctx = context.WithValue(ctx, "Schema", dbSchema)
|
||||
|
||||
ln, err := lang.LanguageFromCode(config.DefaultLanguage)
|
||||
if err != nil {
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/lang"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/config"
|
||||
"git.grassecon.net/urdt/ussd/initializers"
|
||||
@ -28,13 +27,12 @@ import (
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
baseDir = testdataloader.GetBasePath()
|
||||
scriptDir = path.Join("services", "registration")
|
||||
menuSeparator = ": "
|
||||
)
|
||||
|
||||
func init() {
|
||||
initializers.LoadEnvVariables(baseDir)
|
||||
initializers.LoadEnvVariables()
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -43,8 +41,6 @@ func main() {
|
||||
var connStr string
|
||||
var resourceDir string
|
||||
var size uint
|
||||
var database string
|
||||
var dbSchema string
|
||||
var engineDebug bool
|
||||
var host string
|
||||
var port uint
|
||||
@ -74,8 +70,6 @@ func main() {
|
||||
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "Database", database)
|
||||
ctx = context.WithValue(ctx, "Schema", dbSchema)
|
||||
|
||||
ln, err := lang.LanguageFromCode(config.DefaultLanguage)
|
||||
if err != nil {
|
||||
|
@ -17,18 +17,16 @@ import (
|
||||
"git.grassecon.net/urdt/ussd/internal/storage"
|
||||
"git.grassecon.net/urdt/ussd/internal/args"
|
||||
"git.grassecon.net/urdt/ussd/remote"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
baseDir = testdataloader.GetBasePath()
|
||||
scriptDir = path.Join("services", "registration")
|
||||
menuSeparator = ": "
|
||||
)
|
||||
|
||||
func init() {
|
||||
initializers.LoadEnvVariables(baseDir)
|
||||
initializers.LoadEnvVariables()
|
||||
}
|
||||
|
||||
Alfred-mk marked this conversation as resolved
Outdated
|
||||
// TODO: external script automatically generate language handler list from select language vise code OR consider dynamic menu generation script possibility
|
||||
@ -38,8 +36,6 @@ func main() {
|
||||
var connStr string
|
||||
var size uint
|
||||
var sessionId string
|
||||
var database string
|
||||
var dbSchema string
|
||||
var engineDebug bool
|
||||
var resourceDir string
|
||||
var err error
|
||||
@ -72,8 +68,6 @@ func main() {
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
ctx = context.WithValue(ctx, "Database", database)
|
||||
ctx = context.WithValue(ctx, "Schema", dbSchema)
|
||||
|
||||
ln, err := lang.LanguageFromCode(config.DefaultLanguage)
|
||||
if err != nil {
|
||||
|
@ -23,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
initializers.LoadEnvVariables(baseDir)
|
||||
initializers.LoadEnvVariables()
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -9,9 +9,13 @@ import (
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func LoadEnvVariables(baseDir string) {
|
||||
envDir := path.Join(baseDir, ".env")
|
||||
err := godotenv.Load(envDir)
|
||||
func LoadEnvVariables() {
|
||||
LoadEnvVariablesPath(".")
|
||||
}
|
||||
|
||||
func LoadEnvVariablesPath(dir string) {
|
||||
fp := path.Join(dir, ".env")
|
||||
err := godotenv.Load(fp)
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file", err)
|
||||
}
|
||||
|
@ -55,14 +55,6 @@ func (ms *MenuStorageService) getOrCreateDb(ctx context.Context, existingDb db.D
|
||||
connStr := ms.conn.String()
|
||||
dbTyp := ms.conn.DbType()
|
||||
if dbTyp == DBTYPE_POSTGRES {
|
||||
// // Ensure the schema exists
|
||||
// err = ensureSchemaExists(ctx, connStr, schema)
|
||||
// if err != nil {
|
||||
// return nil, fmt.Errorf("failed to ensure schema exists: %w", err)
|
||||
// }
|
||||
//
|
||||
// newDb = postgres.NewPgDb().WithSchema(schema)
|
||||
|
||||
newDb = postgres.NewPgDb()
|
||||
} else if dbTyp == DBTYPE_GDBM {
|
||||
err = ms.ensureDbDir()
|
||||
|
@ -17,17 +17,19 @@ import (
|
||||
"git.grassecon.net/urdt/ussd/internal/testutil/testservice"
|
||||
"git.grassecon.net/urdt/ussd/internal/testutil/testtag"
|
||||
"git.grassecon.net/urdt/ussd/remote"
|
||||
testdataloader "github.com/peteole/testdata-loader"
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
baseDir = testdataloader.GetBasePath()
|
||||
scriptDir = path.Join(baseDir, "services", "registration")
|
||||
selectedDatabase = ""
|
||||
selectedDbSchema = ""
|
||||
)
|
||||
|
||||
func init() {
|
||||
initializers.LoadEnvVariables()
|
||||
initializers.LoadEnvVariablesPath(baseDir)
|
||||
}
|
||||
|
||||
// SetDatabase updates the database used by TestEngine
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"git.grassecon.net/urdt/ussd/internal/storage"
|
||||
"git.grassecon.net/urdt/ussd/internal/testutil"
|
||||
"git.grassecon.net/urdt/ussd/internal/testutil/driver"
|
||||
"github.com/gofrs/uuid"
|
||||
@ -106,7 +105,7 @@ func TestMain(m *testing.M) {
|
||||
defer func() {
|
||||
if *database == "postgres" {
|
||||
ctx := context.Background()
|
||||
connStr := storage.BuildConnStr()
|
||||
connStr := "postgres://" //storage.BuildConnStr()
|
||||
dbConn, err := pgxpool.New(ctx, connStr)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to database for cleanup: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user
I don't think we want to use the
testdataloader
package in main. Let's remove the basedir, and if needed using a different env/config file should be a matter of switches.