From a970a5b885a2c815ca746373e600b146e172120a Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Tue, 20 Jul 2021 01:26:26 +0200 Subject: [PATCH] Add more test --- .../kotlin/fr/postgresjson/ConnectionTest.kt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/test/kotlin/fr/postgresjson/ConnectionTest.kt b/src/test/kotlin/fr/postgresjson/ConnectionTest.kt index c3f5f2c..4bea302 100644 --- a/src/test/kotlin/fr/postgresjson/ConnectionTest.kt +++ b/src/test/kotlin/fr/postgresjson/ConnectionTest.kt @@ -17,6 +17,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.assertThrows import java.util.UUID +import kotlin.test.assertContains import kotlin.test.assertNull @TestInstance(TestInstance.Lifecycle.PER_CLASS) @@ -245,6 +246,52 @@ class ConnectionTest : TestAbstract() { assertEquals(result.offset, 0) } + @Test + fun `test select paginated with no result`() { + assertThrows { + connection.select( + """ + SELECT :name as name, + 10 as total + LIMIT :limit + OFFSET :offset + """.trimIndent(), + 100, + 10, + object : TypeReference>() {}, + mapOf( + "name" to "myName" + ) + ) + }.run { + assertNotNull(message) + assertContains(message!!, "The query has no return") + } + } + + @Test + fun `test select paginated with total was not integer`() { + assertThrows { + connection.select( + """ + SELECT :name as name, + 'plop' as total + LIMIT :limit + OFFSET :offset + """.trimIndent(), + 1, + 10, + object : TypeReference>() {}, + mapOf( + "name" to "myName" + ) + ) + }.run { + assertNotNull(message) + assertContains(message!!, """Column "total" must be an integer""") + } + } + @Test fun `test select paginated without total`() { val exception = assertThrows {