File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
modules/postgresql/src/test/java/org/testcontainers/postgresql Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,28 @@ void testWithAdditionalUrlParamInJdbcUrl() {
122122 }
123123 }
124124
125+ @ Test
126+ void testCustomCredentials () {
127+ try (
128+
129+ PostgreSQLContainer postgres = new PostgreSQLContainer (PostgreSQLTestImages .POSTGRES_TEST_IMAGE )
130+ .withDatabaseName ("my_db" )
131+ .withUsername ("my_user" )
132+ .withPassword ("my_secret" )
133+ ) {
134+ postgres .start ();
135+
136+ // Validações (Asserts)
137+ assertThat (postgres .getDatabaseName ()).isEqualTo ("my_db" );
138+ assertThat (postgres .getUsername ()).isEqualTo ("my_user" );
139+ assertThat (postgres .getPassword ()).isEqualTo ("my_secret" );
140+
141+ // Valida se a URL de conexão reflete as mudanças
142+ String jdbcUrl = postgres .getJdbcUrl ();
143+ assertThat (jdbcUrl ).contains ("/my_db" );
144+ }
145+ }
146+
125147 private void assertHasCorrectExposedAndLivenessCheckPorts (PostgreSQLContainer postgres ) {
126148 assertThat (postgres .getExposedPorts ()).containsExactly (PostgreSQLContainer .POSTGRESQL_PORT );
127149 assertThat (postgres .getLivenessCheckPortNumbers ())
You can’t perform that action at this time.
0 commit comments