flop
flop copied to clipboard
Setup SQLite tests
Context: https://github.com/woylie/flop/issues/446#issuecomment-1895016224
This PR changes test setup so that it could run against multiple databases. I copied the ecto_sql
approach here. A quick summary:
- Tests are not split into
test
andintegration_test
folders. The former can run on their own, the latter require a db. -
mix test
only runs tests intest
folder -
mix test.all
runsmix test
withECTO_ADAPTER={adapter name}
for each adapter defined in@adapters
attribute inmix.exs
. Depending on the env variable,mix test
runs tests inintegration_test/{adapter name}
. Each folder containstest_helper.exs
which runs adapter-specific setup (start repo and run migrations). Each folder also containsall_test.exs
file which imports adapter-agnostic test cases fromintegration_test/cases/
. All adapter-specific tests can be put directly in adapter folder, i.e.integration_test/pg/prefix_test.exs
- I left postgres migrations in
priv/migrations
so that they could be run indev
environment. - SQLite has its own version of migrations as it does not support creating schemas or custom types.
My goal here was to make tests possible, so I didn't look into fixing failing ones.
I hope this helps!