The DAV_SKIP_INIT env var was only set in CI, not locally. db_test_init.go always auto-sets GO_TESTING=1 for local runs — now does the same for DAV_SKIP_INIT, so tests don't panic on DAV init failure. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
37 lines
921 B
Go
37 lines
921 B
Go
//go:build test
|
|
|
|
package db
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// DB is a compatibility alias for Conn, for tests not yet migrated from db.Conn to db.Conn.
|
|
|
|
// savedPOSTGRESHost captures the env value at init time so resetEnv() can
|
|
// always restore it, even after a test temporarily overrides it.
|
|
var savedPOSTGRESHost string
|
|
|
|
func init() {
|
|
// Set defaults for test environment if not already set
|
|
if os.Getenv("POSTGRES_HOST") == "" {
|
|
os.Setenv("POSTGRES_HOST", "localhost")
|
|
}
|
|
savedPOSTGRESHost = os.Getenv("POSTGRES_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_DB") == "" {
|
|
os.Setenv("POSTGRES_DB", "crussell_test")
|
|
}
|
|
if os.Getenv("GO_TESTING") == "" {
|
|
os.Setenv("GO_TESTING", "1")
|
|
}
|
|
if os.Getenv("DAV_SKIP_INIT") == "" {
|
|
os.Setenv("DAV_SKIP_INIT", "1")
|
|
}
|
|
}
|