fix(tests): update database connection strings for CI
Integration Tests / integration-test (push) Failing after 57s
Integration Tests / integration-test (push) Failing after 57s
* Use dynamic host and port for Postgres in tests * Add helper functions for test database host and port
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// testDBHost and testDBPort let CI point the integration suite at a
|
||||
// dynamically-assigned Postgres (TEST_DB_HOST/TEST_DB_PORT), avoiding a fixed
|
||||
// host port that can collide with other jobs on a shared runner. Local dev
|
||||
// keeps working unset, defaulting to the docker-compose test stack.
|
||||
func testDBHost() string {
|
||||
if h := os.Getenv("TEST_DB_HOST"); h != "" {
|
||||
return h
|
||||
}
|
||||
return "127.0.0.1"
|
||||
}
|
||||
|
||||
func testDBPort() int {
|
||||
if p := os.Getenv("TEST_DB_PORT"); p != "" {
|
||||
if n, err := strconv.Atoi(p); err == nil {
|
||||
return n
|
||||
}
|
||||
}
|
||||
return 5433
|
||||
}
|
||||
Reference in New Issue
Block a user