dbHost() only checked TEST_DB_HOST, defaulting to localhost. When the CI workflow removed PG service port mappings (to avoid host port conflicts), all tests using testdb.CreateTestDatabase() failed because localhost:5432 was unreachable inside the job container. The workflow sets POSTGRES_HOST=postgres for the db package's Connect(), but testdb's dbHost() never checked this env var. Add POSTGRES_HOST as a second fallback so all packages using testdb automatically work with the existing CI configuration.
This commit is contained in:
@@ -33,6 +33,9 @@ func dbHost() string {
|
||||
if h := os.Getenv("TEST_DB_HOST"); h != "" {
|
||||
return h
|
||||
}
|
||||
if h := os.Getenv("POSTGRES_HOST"); h != "" {
|
||||
return h
|
||||
}
|
||||
return "localhost"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user