Use In-Memory Database for Tests#79
Conversation
|
After a bit of thought, I think the specific issue we were having was a data race when I think the race happens as such: Thread A creates the file |
Any thoughts on just giving the tempfiles different names? |
jackjohn7
left a comment
There was a problem hiding this comment.
Looks good. I like how it simplifies the test code. However, since it's the generated DB file that we end up using at runtime, it's nice that we get to test against it. Since we're no longer doing that, could you add a test that simply produces the mock database in a tempfile like we do ordinarily and then just produce some dummy data? I want to make sure we still have a mechanism for catching regressions on that front.
No longer initialise the database from the one built at compile-time. Instead, embed the migration.sql and run it at compile.
I changed the initialisation of the database to no longer use the compile-time built database (I'm honestly not sure why we did that to begin with). I also added a test to ensure that the database persists between creation of the |
jackjohn7
left a comment
There was a problem hiding this comment.
Looks good. I think we had done that for a tiny perf optimization that really isn't worth having. Also, be sure that the merge commit message is updated to contain this information as well
Yeah that seems likely. Any potential performance gain would definitely be very minor. |
Switch to using an in-memory database for testing. This makes tests use a bit more memory (though not significantly), but seems to fix the spurious errors that we have been getting in CI.
I am able to force the errors on main locally by using this fish command:
I think the bash equivalent is this, but I haven't tested it:
The issues do not seem to persist locally when using an in-memory database, but this PR should be a better indicator as to whether it persists in CI.
Resolve #62