feature: get migrations from DB

This commit is contained in:
2019-07-02 17:28:52 +02:00
parent 551a6c11cd
commit f48b06b596
5 changed files with 191 additions and 77 deletions

View File

@@ -1,7 +1,9 @@
package fr.postgresjson
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.Test
@@ -14,7 +16,8 @@ class MigrationTest(): TestAbstract() {
fun upQuery() {
val resources = File(this::class.java.getResource("/sql/migrations").toURI())
val m = Migrations(resources, getConnextion())
m.up() `should be equal to` 1
m.up() `should contain` Pair("1", Migration.Status.OK)
m.up().size `should be equal to` 1
}
@Test
@@ -29,14 +32,15 @@ class MigrationTest(): TestAbstract() {
fun downQuery() {
val resources = File(this::class.java.getResource("/sql/migrations").toURI())
val m = Migrations(resources, getConnextion())
m.down() `should be equal to` 1
m.down() `should contain` Pair("1", Migration.Status.OK)
m.down().size `should be equal to` 1
}
@Test
fun `test up and down migrations`() {
val resources = File(this::class.java.getResource("/sql/real_migrations").toURI())
val m = Migrations(resources, getConnextion())
m.test() `should be equal to` 2
m.test() `should be equal to` 2
m.test().size `should be equal to` 2
m.test().size `should be equal to` 2
}
}

View File

@@ -1,2 +1,3 @@
drop schema public cascade;
create schema if not exists public;
drop schema if exists public cascade;
create schema if not exists public;
drop schema if exists migration cascade;