Skip to content

Run integration tests with an in-memory sqlite database instead of a hand-coded fake database #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 10, 2022

Conversation

maxbrunsfeld
Copy link
Collaborator

@maxbrunsfeld maxbrunsfeld commented Nov 10, 2022

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 on libsqlite-sys.

@maxbrunsfeld maxbrunsfeld merged commit eeeaf6d into main Nov 10, 2022
@maxbrunsfeld maxbrunsfeld deleted the tests-use-real-db branch November 10, 2022 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants