github.com/letsencrypt/boulder@v0.20251208.0/test/vars/vars.go (about) 1 package vars 2 3 import ( 4 "fmt" 5 "net" 6 "os" 7 ) 8 9 var dbAddr = func() string { 10 addr := os.Getenv("DB_ADDR") 11 if addr == "" { 12 panic("environment variable DB_ADDR must be set") 13 } 14 _, _, err := net.SplitHostPort(addr) 15 if err != nil { 16 panic(fmt.Sprintf("environment variable DB_ADDR (%s) is not a valid address with host and port: %s", addr, err)) 17 } 18 return addr 19 }() 20 21 func dsn(user, database string) string { 22 return fmt.Sprintf("%s@tcp(%s)/%s", user, dbAddr, database) 23 } 24 25 var ( 26 // DBConnSA is the sa database connection 27 DBConnSA = dsn("sa", "boulder_sa_test") 28 // DBConnSAMailer is the sa mailer database connection 29 DBConnSAMailer = dsn("mailer", "boulder_sa_test") 30 // DBConnSAFullPerms is the sa database connection with full perms 31 DBConnSAFullPerms = dsn("test_setup", "boulder_sa_test") 32 // DBConnSAIntegrationFullPerms is the sa database connection for the 33 // integration test DB, with full perms 34 DBConnSAIntegrationFullPerms = dsn("test_setup", "boulder_sa_integration") 35 // DBInfoSchemaRoot is the root user and the information_schema connection. 36 DBInfoSchemaRoot = dsn("root", "information_schema") 37 // DBConnIncidents is the incidents database connection. 38 DBConnIncidents = dsn("incidents_sa", "incidents_sa_test") 39 // DBConnIncidentsFullPerms is the incidents database connection with full perms. 40 DBConnIncidentsFullPerms = dsn("test_setup", "incidents_sa_test") 41 )