fix: functions migrations

This commit is contained in:
2019-08-02 20:39:30 +02:00
parent 56a141a34c
commit 88d581c529
7 changed files with 54 additions and 8 deletions

View File

@@ -1,11 +1,13 @@
package fr.postgresjson
import fr.postgresjson.connexion.Requester
import fr.postgresjson.migration.Migration
import fr.postgresjson.migration.Migrations
import org.amshove.kluent.`should be equal to`
import org.amshove.kluent.`should contain`
import org.amshove.kluent.invoking
import org.amshove.kluent.shouldThrow
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import java.io.File
@@ -32,6 +34,18 @@ class MigrationTest(): TestAbstract() {
} shouldThrow Migrations.DownMigrationNotDefined::class
}
@Test
fun `run forced down query`() {
val resources = File(this::class.java.getResource("/sql/migrations").toURI())
val m = Migrations(resources, getConnextion())
repeat(3) {
m.down(true).apply {
this `should contain` Pair("1", Migration.Status.OK)
size `should be equal to` 1
}
}
}
@Test
fun `run dry migrations`() {
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
@@ -76,4 +90,20 @@ class MigrationTest(): TestAbstract() {
}
}
}
@Test
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
}
val objTest: RequesterTest.ObjTest? = Requester(getConnextion())
.addFunction(resources)
.getFunction("test_function")
.selectOne(listOf("test", "plip"))
Assertions.assertEquals(objTest!!.id, 3)
Assertions.assertEquals(objTest.name, "test")
}
}