From 29c6d87167189f199fc0e16b584251ff52db5402 Mon Sep 17 00:00:00 2001 From: Lajos Koszti Date: Fri, 10 Nov 2023 10:02:55 +0100 Subject: [PATCH] get test postgres password from env var --- testhelper/psql.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testhelper/psql.go b/testhelper/psql.go index d0a1e19..4ce39da 100644 --- a/testhelper/psql.go +++ b/testhelper/psql.go @@ -2,11 +2,17 @@ package testhelper import ( "fmt" + "os" "github.com/Ajnasz/sekret.link/config" ) // GetPSQLTestConn returns connection string for tests func GetPSQLTestConn() string { - return config.GetConnectionString(fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=disable", "secret_link_test", "Km61HJgJbBjNA0FdABpjDmQxEz008PHAQMA8TLpUbnlaKN7U8G1bQGHk0wsm", "localhost", 5432, "secret_link_test")) + password := os.Getenv("POSTGRES_PASSWORD") + + if password == "" { + password = "sekret_link_test" + } + return config.GetConnectionString(fmt.Sprintf("postgres://%s:%s@%s:%d/%s?sslmode=disable", "postgres", "password", "localhost", 5432, password)) }