use sendQuery if no return is expected

This commit is contained in:
2019-08-04 21:09:24 +02:00
parent cbb86dacc5
commit 24349fc71f
12 changed files with 101 additions and 16 deletions

View File

@@ -79,14 +79,15 @@ class MigrationTest(): TestAbstract() {
@Test
fun `run migrations force down`() {
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
Migrations(resources, getConnextion()).apply {
val resourcesFunctions = File(this::class.java.getResource("/sql/function").toURI())
Migrations(listOf(resources, resourcesFunctions), getConnextion()).apply {
up().apply {
size `should be equal to` 1
size `should be equal to` 6
}
}
Migrations(resources, getConnextion()).apply {
Migrations(listOf(resources, resourcesFunctions), getConnextion()).apply {
forceAllDown().apply {
size `should be equal to` 1
size `should be equal to` 6
}
}
}
@@ -95,7 +96,7 @@ class MigrationTest(): TestAbstract() {
fun `run functions migrations`() {
val resources = File(this::class.java.getResource("/sql/function").toURI())
Migrations(resources, getConnextion()).apply {
run().size `should be equal to` 4
run().size `should be equal to` 5
}
val objTest: RequesterTest.ObjTest? = Requester(getConnextion())

View File

@@ -57,6 +57,28 @@ class RequesterTest: TestAbstract() {
assertEquals(1, result.rowsAffected)
}
@Test
fun `call sendQuery on query`() {
val resources = File(this::class.java.getResource("/sql/query").toURI())
val result = Requester(getConnextion())
.addQuery(resources)
.getQuery("Test/exec")
.sendQuery()
assertEquals(0, result)
}
@Test
fun `call sendQuery on function`() {
val resources = File(this::class.java.getResource("/sql/function").toURI())
val result = Requester(getConnextion())
.addFunction(resources)
.getFunction("function_void")
.sendQuery(listOf("test"))
assertEquals(0, result)
}
@Test
fun `call selectOne on function`() {
val resources = File(this::class.java.getResource("/sql/function").toURI())

View File

@@ -9,8 +9,9 @@ import java.io.File
@TestInstance(PER_CLASS)
abstract class TestAbstract {
private val con = Connection(database = "test", username = "test", password = "test")
protected fun getConnextion(): Connection {
return Connection(database = "test", username = "test", password = "test")
return con
}
@BeforeEach
@@ -24,5 +25,6 @@ abstract class TestAbstract {
fun afterAll() {
val downSQL = File(this::class.java.getResource("/fixtures/down.sql").toURI())
getConnextion().connect().sendQuery(downSQL.readText()).join()
getConnextion().connect().disconnect()
}
}