-
Notifications
You must be signed in to change notification settings - Fork 16
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
Run integration tests against a Postgres container (Testcontainers) #135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we always have to do the same setup in every test fixture, can we make a base class? Maybe something like APIResourceTestFixture
?
Absolutely, I think it's a good idea but outside the scope of the PR. |
improved test speed by ~35% on my machine
I personally think it's in scope since this is the PR that adds the setup that matches a clear potential abstraction. But I don't feel strongly enough to block anything. |
Let's just make that change in its own PR. Don't foresee any clashes with other PRs and stuff. |
Motivation
Integration tests against an in-memory db are not reliable: some SQL requests can work perfectly against the in-memory db and fail on the real database. This PR aims to make running the tests against a real database very simple (no more docker-compose).
Changes summary
Test project:
CI/build changes:
POSTGRES_TEST_PORT
env variable fromexample.env
INTEGRATION_TESTS_DB_BACKEND=InMemory
)New dependencies:
Performance
I've made resetting the database as fast as I could, but keep in mind resetting the db is slow, and often easily avoidable.
API requests in
[SetUp]
also take a lot of time if there are a lot of tests in the class, so they should be kept to a minimum as well.