test: getRequestFromFunction
This commit is contained in:
@@ -12,7 +12,15 @@ class RequestTest {
|
||||
@Test
|
||||
fun getRequestFromFile() {
|
||||
val resources = File(this::class.java.getResource("/sql/query").toURI())
|
||||
val objTest: ObjTest? = Connection(queriesDirectory = resources).getQuery("Test/test").selectOne()
|
||||
val objTest: ObjTest? = Connection(queriesDirectory = resources).getQuery("Test/selectOne").selectOne()
|
||||
assertTrue(objTest!!.id == 2)
|
||||
assertTrue(objTest.name == "test")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getRequestFromFunction() {
|
||||
val resources = File(this::class.java.getResource("/sql/function").toURI())
|
||||
val objTest: ObjTest? = Connection(functionsDirectory = resources).getFunction("test_function").selectOne()
|
||||
assertTrue(objTest!!.id == 2)
|
||||
assertTrue(objTest.name == "test")
|
||||
}
|
||||
|
||||
8
src/test/resources/sql/function/Test/function_test.sql
Normal file
8
src/test/resources/sql/function/Test/function_test.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
CREATE OR REPLACE FUNCTION test_function (name text, IN hi text default 'hello', out result json)
|
||||
LANGUAGE plpgsql
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
result = json_build_object('id', 2, 'name', 'test');
|
||||
END;
|
||||
$$
|
||||
Reference in New Issue
Block a user