Skip to content

Instantly share code, notes, and snippets.

@FRosner
Created June 7, 2019 09:44
Show Gist options
  • Save FRosner/1e9699c2880937c5bae2c7df66ff0e36 to your computer and use it in GitHub Desktop.
Save FRosner/1e9699c2880937c5bae2c7df66ff0e36 to your computer and use it in GitHub Desktop.
@Testcontainers
class DatabaseMigrationsTest {
@Container
val postgresContainer = PostgresContainer("postgres:10.6")
.withDatabaseName("db")
.withUsername("user")
.withPassword("password")
@Test
fun testSomethingOnYourCustomerTable() {
testAfterMigration(postgresContainer) { pgClient ->
val one = pgClient.preparedQueryAwait("select 1 from customers")
.first()
.getInt(0)
assertThat(one).isEqualTo(1)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment