-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45508 from giamma-frangipane/main
Added support for multiple init scripts
- Loading branch information
Showing
10 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...postgresql/deployment/DevServicesPostgresqlDatasourceWithMultipleInitScriptsTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.quarkus.jdbc.postgresql.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.sql.CallableStatement; | ||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class DevServicesPostgresqlDatasourceWithMultipleInitScriptsTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot(javaArchive -> javaArchive.addAsResource("init-db.sql")) | ||
.withApplicationRoot(javaArchive -> javaArchive.addAsResource("init-db-2.sql")) | ||
.overrideConfigKey("quarkus.datasource.db-kind", "postgresql") | ||
.overrideConfigKey("quarkus.datasource.devservices.init-script-path", "init-db.sql, init-db-2.sql"); | ||
|
||
@Inject | ||
DataSource ds; | ||
|
||
@Test | ||
@DisplayName("Test if init-script-path executed successfully") | ||
public void testDatasource() throws Exception { | ||
int result = 0; | ||
try (Connection con = ds.getConnection(); | ||
CallableStatement cs = con.prepareCall("SELECT my_func()"); | ||
ResultSet rs = cs.executeQuery()) { | ||
if (rs.next()) { | ||
result = rs.getInt(1); | ||
} | ||
} | ||
assertEquals(100, result, "The first init script should have been executed"); | ||
try (Connection con = ds.getConnection(); | ||
CallableStatement cs = con.prepareCall("SELECT my_func_2()"); | ||
ResultSet rs = cs.executeQuery()) { | ||
if (rs.next()) { | ||
result = rs.getInt(1); | ||
} | ||
} | ||
assertEquals(200, result, "The second init script should have been executed"); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
extensions/jdbc/jdbc-postgresql/deployment/src/test/resources/init-db-2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE OR REPLACE FUNCTION my_func_2() RETURNS integer LANGUAGE plpgsql as $func$ BEGIN return 200; END $func$; |