github.com/acoshift/pgsql@v0.15.3/pgstmt/init_test.go (about) 1 package pgstmt_test 2 3 import ( 4 "database/sql" 5 "os" 6 "testing" 7 ) 8 9 func open(t *testing.T) *sql.DB { 10 t.Helper() 11 12 dbURL := os.Getenv("DB_URL") 13 if dbURL == "" { 14 dbURL = "postgres://localhost:5432/postgres?sslmode=disable" 15 } 16 db, err := sql.Open("postgres", dbURL) 17 if err != nil { 18 t.Fatalf("open database connection error; %v", err) 19 } 20 return db 21 }