Skip to content

Commit

Permalink
get test postgres password from env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajnasz committed Nov 10, 2023
1 parent 10e50de commit 29c6d87
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion testhelper/psql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 29c6d87

Please sign in to comment.