Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ void testWithAdditionalUrlParamInJdbcUrl() {
}
}

@Test
void testCustomCredentials() {
try (

PostgreSQLContainer postgres = new PostgreSQLContainer(PostgreSQLTestImages.POSTGRES_TEST_IMAGE)
.withDatabaseName("my_db")
.withUsername("my_user")
.withPassword("my_secret")
) {
postgres.start();

// Assertions
assertThat(postgres.getDatabaseName()).isEqualTo("my_db");
assertThat(postgres.getUsername()).isEqualTo("my_user");
assertThat(postgres.getPassword()).isEqualTo("my_secret");

// Verify that the connection URL reflects the changes
String jdbcUrl = postgres.getJdbcUrl();
assertThat(jdbcUrl).contains("/my_db");
}
}

private void assertHasCorrectExposedAndLivenessCheckPorts(PostgreSQLContainer postgres) {
assertThat(postgres.getExposedPorts()).containsExactly(PostgreSQLContainer.POSTGRESQL_PORT);
assertThat(postgres.getLivenessCheckPortNumbers())
Expand Down