Skip to content

Commit

Permalink
stores: use DBConfigFromEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Feb 19, 2024
1 parent aa121cc commit 6c42f1b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions stores/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,25 @@ func newTestSQLStore(t *testing.T, cfg testSQLStoreConfig) *testSQLStore {
if dir == "" {
dir = t.TempDir()
}
dbURI := cfg.dbURI

dbURI, dbUser, dbPassword, dbName := DBConfigFromEnv()
if dbURI == "" {
dbURI = os.Getenv("RENTERD_DB_URI")
dbURI = cfg.dbURI
}
if cfg.persistent && dbURI != "" {
t.Fatal("invalid store config, can't use both persistent and dbURI")
}
dbUser := cfg.dbUser
if dbUser == "" {
dbUser = os.Getenv("RENTERD_DB_USER")
dbUser = cfg.dbUser
}
dbPassword := cfg.dbPassword
if dbPassword == "" {
dbPassword = os.Getenv("RENTERD_DB_PASSWORD")
dbPassword = cfg.dbPassword
}
dbName := cfg.dbName
if dbName == "" {
if n := os.Getenv("RENTERD_DB_NAME"); n != "" {
dbName = n
} else {
if cfg.dbName == "" {
dbName = hex.EncodeToString(frand.Bytes(32)) // random name for db
} else {
dbName = cfg.dbName
}
}
dbMetricsName := cfg.dbMetricsName
Expand Down

0 comments on commit 6c42f1b

Please sign in to comment.