aboutsummaryrefslogtreecommitdiff
path: root/syncapi/storage/tables/interface.go
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2022-04-11 10:23:01 +0100
committerGitHub <noreply@github.com>2022-04-11 10:23:01 +0100
commitea92f80c128bcff0fd4e02df40b272f7d90a97da (patch)
tree18882388247345842a9fcec75d421a6e6df7c586 /syncapi/storage/tables/interface.go
parent69f2ff7c82abe0731a05febde88098f4cd34ab8d (diff)
Add database namespacing for unit tests (#2340)
* Add database namespacing for unit tests Background: Running `go test ./...` will run tests in different packages concurrently. This can be stopped or limited by using `-p 1` (no concurrency). We want concurrency, but this causes problems when running Postgres DBs in CI. The problem is that, in CI, we have 1x postgres server exposing 1x postgres DB, which we wipe clean at the end of each test via `defer close()`. When tests run concurrently, calls to `close()` will delete data/tables which other tests are currently using, causing havoc. Fix this by: - Creating a database per package. - Namespacing the database name by a hash of the current working directory (the directory containing those `_test.go` files) This is exactly what SQLite does, quite unintentionally, via the use of `file:dendrite_test.db`, which dumps the file into the current working directory which is the package running the tests, hence deleting the file is safe when running concurrently. * Linting * Don't create the database in a txn * dupe db is not an error
Diffstat (limited to 'syncapi/storage/tables/interface.go')
0 files changed, 0 insertions, 0 deletions