From a11d2538e92d4b70432f83363041306e349fb173 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Thu, 25 Jun 2026 00:59:22 +0100 Subject: [PATCH] ci: fix db test init to respect POSTGRES_HOST from env --- backend/db/db_test_init.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/db/db_test_init.go b/backend/db/db_test_init.go index 5e57ddb..4940583 100644 --- a/backend/db/db_test_init.go +++ b/backend/db/db_test_init.go @@ -11,15 +11,21 @@ import ( func init() { // Set defaults for test environment if not already set + host := os.Getenv("POSTGRES_HOST") + if host == "" { + if h := os.Getenv("TEST_DB_HOST"); h != "" { + host = h + } else { + host = "localhost" + } + os.Setenv("POSTGRES_HOST", host) + } if os.Getenv("POSTGRES_USER") == "" { os.Setenv("POSTGRES_USER", "myuser") } if os.Getenv("POSTGRES_PASSWORD") == "" { os.Setenv("POSTGRES_PASSWORD", "mypassword") } - if os.Getenv("POSTGRES_HOST") == "" { - os.Setenv("POSTGRES_HOST", "localhost") - } if os.Getenv("POSTGRES_DB") == "" { os.Setenv("POSTGRES_DB", "crussell_test") }