From 0288a57ed9e3a930b39a5863151cd3854267bfba Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sun, 18 Jul 2021 02:54:35 +0200 Subject: [PATCH] Add more tests --- .../kotlin/fr/postgresjson/ConnectionTest.kt | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/test/kotlin/fr/postgresjson/ConnectionTest.kt b/src/test/kotlin/fr/postgresjson/ConnectionTest.kt index 6f5ef82..b5afa7e 100644 --- a/src/test/kotlin/fr/postgresjson/ConnectionTest.kt +++ b/src/test/kotlin/fr/postgresjson/ConnectionTest.kt @@ -139,11 +139,6 @@ class ConnectionTest : TestAbstract() { @Test fun `select with named parameters`() { - val params: Map = mapOf( - "first" to "ff", - "third" to 123, - "second" to "sec" - ) val result: List = connection.select( """ SELECT json_build_array( @@ -151,7 +146,29 @@ class ConnectionTest : TestAbstract() { json_build_object('first', :first::text, 'second', :second::text, 'third', :third::int) ) """.trimIndent(), - params + mapOf( + "first" to "ff", + "third" to 123, + "second" to "sec" + ) + ) + assertEquals(result[0].first, "ff") + assertEquals(result[0].second, "sec") + assertEquals(result[0].third, 123) + } + + @Test + fun `select with named parameters as vararg of Pair`() { + val result: List = connection.select( + """ + SELECT json_build_array( + json_build_object('first', :first::text, 'second', :second::text, 'third', :third::int), + json_build_object('first', :first::text, 'second', :second::text, 'third', :third::int) + ) + """.trimIndent(), + "first" to "ff", + "third" to 123, + "second" to "sec" ) assertEquals(result[0].first, "ff") assertEquals(result[0].second, "sec")