TestDatabaseURL returns `TEST_DATABASE_URL` or a default URL pointing to `river_test` and with suitable connection configuration defaults.
()
| 215 | // TestDatabaseURL returns `TEST_DATABASE_URL` or a default URL pointing to |
| 216 | // `river_test` and with suitable connection configuration defaults. |
| 217 | func TestDatabaseURL() string { |
| 218 | return cmp.Or( |
| 219 | os.Getenv("TEST_DATABASE_URL"), |
| 220 | |
| 221 | // 100 conns is the default maximum for Homebrew. |
| 222 | // |
| 223 | // It'd be nice to be able to set this number really high because it'd |
| 224 | // mean less waiting time acquiring connections in tests, but with |
| 225 | // default settings, contention between tests/test packages leading to |
| 226 | // exhausion on the Postgres server is definitely a problem. At numbers |
| 227 | // >75 I started seeing a lot of errors between tests within a single |
| 228 | // package, and worse yet, at numbers >=20 I saw major problems between |
| 229 | // packages (i.e. as parallel packages run at the same time). |
| 230 | // |
| 231 | // 15 is about as high as I found I could set it while keeping test runs |
| 232 | // stable. This could be much higher in areas where we know Postgres is |
| 233 | // configured with more allowed max connections. |
| 234 | "postgres://localhost:5432/river_test?pool_max_conns=15&sslmode=disable", |
| 235 | ) |
| 236 | } |
| 237 | |
| 238 | // TimeStub implements baseservice.TimeGeneratorWithStub to allow time to be |
| 239 | // stubbed in tests. |
no outgoing calls
no test coverage detected
searching dependent graphs…