improve-tests #28
@@ -235,7 +235,7 @@ class Connection(
|
|||||||
return """(?<!\?)(\?)(?!\?)"""
|
return """(?<!\?)(\?)(?!\?)"""
|
||||||
.toRegex(RegexOption.IGNORE_CASE)
|
.toRegex(RegexOption.IGNORE_CASE)
|
||||||
.replace(sql) {
|
.replace(sql) {
|
||||||
values[i]
|
values.getOrNull(i)
|
||||||
?.toString()
|
?.toString()
|
||||||
?.also { ++i }
|
?.also { ++i }
|
||||||
?.let(this::escapeParameter)
|
?.let(this::escapeParameter)
|
||||||
|
|||||||
@@ -236,10 +236,7 @@ class RequesterTest : TestAbstract() {
|
|||||||
assertThrows(QueryError::class.java) {
|
assertThrows(QueryError::class.java) {
|
||||||
Requester(connection, queriesDirectory = resources)
|
Requester(connection, queriesDirectory = resources)
|
||||||
.getQuery("selectMultipleDifferentArgs")
|
.getQuery("selectMultipleDifferentArgs")
|
||||||
.sendQuery("first" to "firstName").run {
|
.sendQuery("first" to "firstName")
|
||||||
assertEquals("firstName", rows[0].getString(0))
|
|
||||||
assertEquals("secondName", rows[0].getString(1))
|
|
||||||
}
|
|
||||||
}.let {
|
}.let {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"""
|
"""
|
||||||
@@ -253,6 +250,27 @@ class RequesterTest : TestAbstract() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `call sendQuery with wrong number of arguments as list`() {
|
||||||
|
val resources = this::class.java.getResource("/sql/query")?.toURI()
|
||||||
|
|
||||||
|
assertThrows(QueryError::class.java) {
|
||||||
|
Requester(connection, queriesDirectory = resources)
|
||||||
|
.getQuery("selectMultipleDifferentArgs")
|
||||||
|
.sendQuery(listOf("firstName"))
|
||||||
|
}.let {
|
||||||
|
assertEquals(
|
||||||
|
"""
|
||||||
|
Parameter 1 missing
|
||||||
|
|
||||||
|
> firstName
|
||||||
|
> SELECT ?::text as "firstName", ?::text as "secondName";
|
||||||
|
""".trimIndent(),
|
||||||
|
it.message
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `call exec on function with pair as arguments`() {
|
fun `call exec on function with pair as arguments`() {
|
||||||
val resources = this::class.java.getResource("/sql/function/Test")?.toURI()
|
val resources = this::class.java.getResource("/sql/function/Test")?.toURI()
|
||||||
|
|||||||
Reference in New Issue
Block a user