flop icon indicating copy to clipboard operation
flop copied to clipboard

Setup SQLite tests

Open martosaur opened this issue 7 months ago • 0 comments

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:

  1. Tests are not split into test and integration_test folders. The former can run on their own, the latter require a db.
  2. mix test only runs tests in test folder
  3. mix test.all runs mix test with ECTO_ADAPTER={adapter name} for each adapter defined in @adapters attribute in mix.exs. Depending on the env variable, mix test runs tests in integration_test/{adapter name}. Each folder contains test_helper.exs which runs adapter-specific setup (start repo and run migrations). Each folder also contains all_test.exs file which imports adapter-agnostic test cases from integration_test/cases/. All adapter-specific tests can be put directly in adapter folder, i.e. integration_test/pg/prefix_test.exs
  4. I left postgres migrations in priv/migrations so that they could be run in dev environment.
  5. 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!

martosaur avatar Jul 06 '24 02:07 martosaur