cryptomator / hub

Cryptomator Hub helps you manage vaults in large teams
GNU Affero General Public License v3.0
41 stars 9 forks source link

replace H2 with Postgres in `%test` profile #182

Closed overheadhunter closed 1 year ago

overheadhunter commented 1 year ago

In order to use non-ANSI-SQL features, we need to make sure all profiles rely on the same dialect. So we need to drop h2 in unit tests, replacing it with Postgres (provided via testcontainers).

Sadly, this breaks @FlywayTest, so I needed to change a lot of unit tests to make sure, they don't modify anything prepared via V9999__Test_Data.sql. If a test wants to delete/change something, it should prepare its own data. As a general rule, a unit tests should "leave it (the database) as it found it". This is achieved in one of the following ways:

  1. In some cases, @TestTransaction could be use to rollback such changes. This requires all to happen in the same transaction, obviously. So this is not feasible when using REST assured, as the serverside code is running outside the test transaction.
  2. In other cases a @AfterAll function could do some cleanup.
  3. For @Ordered tests creation and deletion could be run in pairs
  4. If every other approach fails, the test itself needs to do the cleanup work. Ugly but simple.

Especially in VaultResourceTest I regrouped some of the nested tests and tried to make all tests run on the same set of common test data.

overheadhunter commented 1 year ago

Btw: Diff is +258 −383 😎