Files
popertotsandSisyphus a3243fab27 fix: auto-set DAV_SKIP_INIT=1 in test init to match local GO_TESTING behavior
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>
2026-07-11 15:13:51 +01:00

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")
}
}