Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Document the SYNAPSE_TEST_PERSIST_SQLITE_DB unit test env var (#11715)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 authored Jan 10, 2022
1 parent ffd227c commit 7c3408d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/11715.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document the new `SYNAPSE_TEST_PERSIST_SQLITE_DB` environment variable in the contributing guide.
21 changes: 21 additions & 0 deletions docs/development/contributing_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,27 @@ To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`:
SYNAPSE_TEST_LOG_LEVEL=DEBUG trial tests
```

By default, tests will use an in-memory SQLite database for test data. For additional
help with debugging, one can use an on-disk SQLite database file instead, in order to
review database state during and after running tests. This can be done by setting
the `SYNAPSE_TEST_PERSIST_SQLITE_DB` environment variable. Doing so will cause the
database state to be stored in a file named `test.db` under the trial process'
working directory. Typically, this ends up being `_trial_temp/test.db`. For example:

```sh
SYNAPSE_TEST_PERSIST_SQLITE_DB=1 trial tests
```

The database file can then be inspected with:

```sh
sqlite3 _trial_temp/test.db
```

Note that the database file is cleared at the beginning of each test run. Thus it
will always only contain the data generated by the *last run test*. Though generally
when debugging, one is only running a single test anyway.

### Running tests under PostgreSQL

Invoking `trial` as above will use an in-memory SQLite database. This is great for
Expand Down

0 comments on commit 7c3408d

Please sign in to comment.