Skip to content

Commit

Permalink
fix: try to make itests work
Browse files Browse the repository at this point in the history
Fixes #874
  • Loading branch information
Lars Bilger committed Oct 4, 2023
1 parent ce28530 commit 95b91cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion view/jpa/src/test/resources/application-itest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ spring:
generate-ddl: true
hibernate.ddl-auto: create-drop
datasource:
url: jdbc:h2:mem:testdb;MODE=PostgreSQL;INIT=create schema if not exists PUBLIC;DB_CLOSE_DELAY=-1;NON_KEYWORDS=VALUE;DB_CLOSE_ON_EXIT=FALSE
# Explanation for the `random.uuid`: Spring caches application contexts for tests (see https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/ctx-management/caching.html).
# If each context uses the same database, we can get a situation where context A is initialized, then context B is initialized and shut down, then context A is reused. But the
# shutdown of context B has destroyed (dropped the schema of) the shared database, so the second test using context A will find the database in an unexpected state and fails.
# Adding a random identifier to the database name ensures that each context gets its own database that it can initialize and tear down according to its own lifecycle.
url: jdbc:h2:mem:testdb-${random.uuid};MODE=PostgreSQL;INIT=create schema if not exists PUBLIC;DB_CLOSE_DELAY=-1;NON_KEYWORDS=VALUE
username: sa
password: sa
hikari:
Expand Down

0 comments on commit 95b91cb

Please sign in to comment.