From 6c42f1b3b0b35980de75fe866395b997bf048bcd Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 19 Feb 2024 13:31:37 +0100 Subject: [PATCH] stores: use DBConfigFromEnv --- stores/sql_test.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/stores/sql_test.go b/stores/sql_test.go index 793601932..dfa6594e2 100644 --- a/stores/sql_test.go +++ b/stores/sql_test.go @@ -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