commit 52d5b56c65c9e7043e7cf205328f4cdb94662cd5 parent c05b1eb6a8ae5a44c62cd9735a9ee7af120e1e4d Author: MS <ms@taler.net> Date: Wed, 23 Nov 2022 20:05:03 +0100 moving code Diffstat:
| M | nexus/src/test/kotlin/DBTest.kt | | | 26 | +------------------------- |
| M | nexus/src/test/kotlin/SelfContainedDBTest.kt | | | 24 | ------------------------ |
2 files changed, 1 insertion(+), 49 deletions(-)
diff --git a/nexus/src/test/kotlin/DBTest.kt b/nexus/src/test/kotlin/DBTest.kt @@ -4,33 +4,9 @@ import org.jetbrains.exposed.exceptions.ExposedSQLException import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.transaction import org.junit.Test +import withTestDatabase import java.io.File -/** - * Run a block after connecting to the test database. - * Cleans up the DB file afterwards. - */ -fun withTestDatabase(f: () -> Unit) { - val dbfile = "jdbc:sqlite:/tmp/nexus-test.sqlite3" - File(dbfile).also { - if (it.exists()) { - it.delete() - } - } - Database.connect("jdbc:sqlite:$dbfile") - dbDropTables(dbfile) - try { - f() - } - finally { - File(dbfile).also { - if (it.exists()) { - it.delete() - } - } - } -} - object MyTable : Table() { val col1 = text("col1") val col2 = text("col2") diff --git a/nexus/src/test/kotlin/SelfContainedDBTest.kt b/nexus/src/test/kotlin/SelfContainedDBTest.kt @@ -13,30 +13,6 @@ import org.jetbrains.exposed.sql.transactions.transaction import org.junit.Test import java.io.File -/** - * Run a block after connecting to the test database. - * Cleans up the DB file afterwards. - */ -fun withTestDatabase(f: () -> Unit) { - val dbfile = "test-db.sqlite3" - File(dbfile).also { - if (it.exists()) { - it.delete() - } - } - Database.connect("jdbc:sqlite:$dbfile", "org.sqlite.JDBC") - try { - f() - } - finally { - File(dbfile).also { - if (it.exists()) { - it.delete() - } - } - } -} - object ContainedTableWithIntId : IntIdTable() { val column = text("column") }