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