Add more test
This commit is contained in:
@@ -235,7 +235,7 @@ class Connection(
|
||||
return """(?<!\?)(\?)(?!\?)"""
|
||||
.toRegex(RegexOption.IGNORE_CASE)
|
||||
.replace(sql) {
|
||||
values[i]
|
||||
values.getOrNull(i)
|
||||
?.toString()
|
||||
?.also { ++i }
|
||||
?.let(this::escapeParameter)
|
||||
|
||||
@@ -236,10 +236,7 @@ class RequesterTest : TestAbstract() {
|
||||
assertThrows(QueryError::class.java) {
|
||||
Requester(connection, queriesDirectory = resources)
|
||||
.getQuery("selectMultipleDifferentArgs")
|
||||
.sendQuery("first" to "firstName").run {
|
||||
assertEquals("firstName", rows[0].getString(0))
|
||||
assertEquals("secondName", rows[0].getString(1))
|
||||
}
|
||||
.sendQuery("first" to "firstName")
|
||||
}.let {
|
||||
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
|
||||
fun `call exec on function with pair as arguments`() {
|
||||
val resources = this::class.java.getResource("/sql/function/Test")?.toURI()
|
||||
|
||||
Reference in New Issue
Block a user