Files
Crussell/backend/db/db_test_init.go
T
popertotsandSisyphus 510828c924
CI / Go vulnerabilities (push) Successful in 1m10s
CI / Build & Vet (push) Successful in 1m39s
CI / Frontend build (gate) (push) Successful in 1m42s
CI / Frontend QC (audit) (push) Successful in 56s
CI / Frontend QC (typecheck) (push) Successful in 1m36s
CI / Frontend QC (lint) (push) Successful in 1m51s
CI / Tests (prod) (push) Has been cancelled
CI / Tests (dev) (push) Has been cancelled
CI / Race (prod) (push) Has been cancelled
CI / Race (dev) (push) Has been cancelled
chore: run go fix for Go 1.26 modernization
106 files: interface{}→any, strings.Split→SplitSeq, CutPrefix/Cut, strings.Builder, slices.Contains, remove redundant // +build directives, gofmt import ordering and indentation.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-09 17:25:23 +01:00

34 lines
845 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")
}
}