Run integration tests with an in-memory sqlite database instead of a hand-coded fake database #1872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As the
collab
server starts to store more and more state in its database (as opposed to in memory), it will become more and more inconvenient to maintain our "Fake Db", which we currently use for integration tests, in order to avoid the slowness of Postgres.This PR replaces the
Db
trait (which previously had two implementations: fake and Postgres) with a generic struct that works with both Postgres and Sqlite. Some database methods are not implemented for Sqlite (since they aren't run during integration tests). And some methods are implemented slightly differently for Sqlite than for Postgres, because of differences in the SQL dialect. But most of our queries work identically against Postgres and Sqlite.Like before, we have tests for the
Db
itself which assert that the Sqlite and Postgres implementations behave the same.Note - This PR also removes all the remaining code for chat and for project activity tracking. Those features were both no longer used, and were complicating our database work, so we decided to go ahead and 🔥 them.
Note - This updates our
sqlx
dependency to use a fork, because of this change that I needed to make to sqlx's dependency onlibsqlite-sys
.