Extract Reified method to Extension
Add update method
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package fr.postgresjson
|
||||
|
||||
import fr.postgresjson.connexion.Requester
|
||||
import fr.postgresjson.connexion.selectOne
|
||||
import fr.postgresjson.migration.Migration
|
||||
import fr.postgresjson.migration.Migrations
|
||||
import org.amshove.kluent.`should be equal to`
|
||||
@@ -13,10 +14,10 @@ import org.junit.jupiter.api.TestInstance
|
||||
import java.util.UUID
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class MigrationTest() : TestAbstract() {
|
||||
class MigrationTest : TestAbstract() {
|
||||
@Test
|
||||
fun `run up query`() {
|
||||
val resources = this::class.java.getResource("/sql/migrations").toURI()
|
||||
val resources = this::class.java.getResource("/sql/migrations")!!.toURI()
|
||||
val m = Migrations(connection, resources)
|
||||
m.up().apply {
|
||||
this `should contain` Pair("1", Migration.Status.OK)
|
||||
@@ -28,7 +29,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `migration up Query should throw error if no down`() {
|
||||
val resources = this::class.java.getResource("/sql/migration_without_down").toURI()
|
||||
val resources = this::class.java.getResource("/sql/migration_without_down")!!.toURI()
|
||||
invoking {
|
||||
Migrations(resources, connection)
|
||||
} shouldThrow Migrations.DownMigrationNotDefined::class
|
||||
@@ -36,7 +37,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run forced down query`() {
|
||||
val resources = this::class.java.getResource("/sql/migrations").toURI()
|
||||
val resources = this::class.java.getResource("/sql/migrations")!!.toURI()
|
||||
val m = Migrations(resources, connection)
|
||||
repeat(3) {
|
||||
m.down(true).apply {
|
||||
@@ -48,7 +49,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run dry migrations`() {
|
||||
val resources = this::class.java.getResource("/sql/real_migrations").toURI()
|
||||
val resources = this::class.java.getResource("/sql/real_migrations")!!.toURI()
|
||||
Migrations(resources, connection).apply {
|
||||
runDry().size `should be equal to` 2
|
||||
}
|
||||
@@ -59,7 +60,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run dry migrations launch twice`() {
|
||||
val resources = this::class.java.getResource("/sql/real_migrations").toURI()
|
||||
val resources = this::class.java.getResource("/sql/real_migrations")!!.toURI()
|
||||
Migrations(resources, connection).apply {
|
||||
runDry().size `should be equal to` 2
|
||||
runDry().size `should be equal to` 2
|
||||
@@ -68,7 +69,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run migrations`() {
|
||||
val resources = this::class.java.getResource("/sql/real_migrations").toURI()
|
||||
val resources = this::class.java.getResource("/sql/real_migrations")!!.toURI()
|
||||
Migrations(resources, connection).apply {
|
||||
run().apply {
|
||||
size `should be equal to` 1
|
||||
@@ -78,8 +79,8 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run migrations force down`() {
|
||||
val resources = this::class.java.getResource("/sql/real_migrations").toURI()
|
||||
val resourcesFunctions = this::class.java.getResource("/sql/function/Test").toURI()
|
||||
val resources = this::class.java.getResource("/sql/real_migrations")!!.toURI()
|
||||
val resourcesFunctions = this::class.java.getResource("/sql/function/Test")!!.toURI()
|
||||
Migrations(listOf(resources, resourcesFunctions), connection).apply {
|
||||
up().apply {
|
||||
size `should be equal to` 6
|
||||
@@ -94,7 +95,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run functions migrations`() {
|
||||
val resources = this::class.java.getResource("/sql/function/Test").toURI()
|
||||
val resources = this::class.java.getResource("/sql/function/Test")!!.toURI()
|
||||
Migrations(resources, connection).apply {
|
||||
run().size `should be equal to` 5
|
||||
}
|
||||
@@ -109,7 +110,7 @@ class MigrationTest() : TestAbstract() {
|
||||
|
||||
@Test
|
||||
fun `run functions migrations and drop if exist`() {
|
||||
val resources = this::class.java.getResource("/sql/function/Test1").toURI()
|
||||
val resources = this::class.java.getResource("/sql/function/Test1")!!.toURI()
|
||||
Migrations(resources, connection).apply {
|
||||
run().size `should be equal to` 1
|
||||
}
|
||||
@@ -121,7 +122,7 @@ class MigrationTest() : TestAbstract() {
|
||||
Assertions.assertEquals(objTest!!.id, UUID.fromString("457daad5-4f1b-4eb7-80ec-6882adb8cc7d"))
|
||||
Assertions.assertEquals(objTest.name, "test")
|
||||
|
||||
val resources2 = this::class.java.getResource("/sql/function/Test2").toURI()
|
||||
val resources2 = this::class.java.getResource("/sql/function/Test2")!!.toURI()
|
||||
Migrations(resources2, connection).apply {
|
||||
run().size `should be equal to` 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user