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

Commit 7c3408d

Browse files
Document the SYNAPSE_TEST_PERSIST_SQLITE_DB unit test env var (#11715)
1 parent ffd227c commit 7c3408d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

changelog.d/11715.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document the new `SYNAPSE_TEST_PERSIST_SQLITE_DB` environment variable in the contributing guide.

docs/development/contributing_guide.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,27 @@ To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`:
169169
SYNAPSE_TEST_LOG_LEVEL=DEBUG trial tests
170170
```
171171

172+
By default, tests will use an in-memory SQLite database for test data. For additional
173+
help with debugging, one can use an on-disk SQLite database file instead, in order to
174+
review database state during and after running tests. This can be done by setting
175+
the `SYNAPSE_TEST_PERSIST_SQLITE_DB` environment variable. Doing so will cause the
176+
database state to be stored in a file named `test.db` under the trial process'
177+
working directory. Typically, this ends up being `_trial_temp/test.db`. For example:
178+
179+
```sh
180+
SYNAPSE_TEST_PERSIST_SQLITE_DB=1 trial tests
181+
```
182+
183+
The database file can then be inspected with:
184+
185+
```sh
186+
sqlite3 _trial_temp/test.db
187+
```
188+
189+
Note that the database file is cleared at the beginning of each test run. Thus it
190+
will always only contain the data generated by the *last run test*. Though generally
191+
when debugging, one is only running a single test anyway.
192+
172193
### Running tests under PostgreSQL
173194

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

0 commit comments

Comments
 (0)