[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: flush before using entity in a foreign
From: |
gnunet |
Subject: |
[libeufin] branch master updated: flush before using entity in a foreign key column |
Date: |
Thu, 04 Jun 2020 20:48:11 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new f8c3bc1 flush before using entity in a foreign key column
f8c3bc1 is described below
commit f8c3bc1e9d29d7d9af6f35fb77e46cfe183c8225
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Fri Jun 5 00:16:39 2020 +0530
flush before using entity in a foreign key column
---
nexus/src/test/kotlin/DBTest.kt | 77 ++++++++++++++++++++++++++++-------------
1 file changed, 52 insertions(+), 25 deletions(-)
diff --git a/nexus/src/test/kotlin/DBTest.kt b/nexus/src/test/kotlin/DBTest.kt
index 250e9ec..933fa98 100644
--- a/nexus/src/test/kotlin/DBTest.kt
+++ b/nexus/src/test/kotlin/DBTest.kt
@@ -6,35 +6,62 @@ import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.addLogger
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 = "nexus-test.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()
+ }
+ }
+ }
+}
+
class DBTest {
@Test
fun facadeConfigTest() {
- Database.connect("jdbc:sqlite:on-the-fly-db.sqlite3",
"org.sqlite.JDBC")
- val talerConfig = transaction {
- addLogger(StdOutSqlLogger)
- SchemaUtils.create(
- FacadesTable,
- TalerFacadeConfigsTable,
- NexusUsersTable
- )
- TalerFacadeConfigEntity.new {
- bankAccount = "b"
- bankConnection = "b"
- reserveTransferLevel = "any"
- intervalIncrement = "any"
- }
- }
- transaction {
- val user = NexusUserEntity.new("u") {
- passwordHash = "x"
- superuser = true
- }
- FacadeEntity.new("my-id") {
- type = "any"
- creator = user
- config = talerConfig
- highestSeenMsgID = 0
+ withTestDatabase {
+ transaction {
+ addLogger(StdOutSqlLogger)
+ SchemaUtils.create(
+ FacadesTable,
+ TalerFacadeConfigsTable,
+ NexusUsersTable
+ )
+ val talerConfig = TalerFacadeConfigEntity.new {
+ bankAccount = "b"
+ bankConnection = "b"
+ reserveTransferLevel = "any"
+ intervalIncrement = "any"
+ }
+ talerConfig.id
+ talerConfig.flush()
+ val user = NexusUserEntity.new("u") {
+ passwordHash = "x"
+ superuser = true
+ }
+ FacadeEntity.new("my-id") {
+ type = "any"
+ creator = user
+ config = talerConfig
+ highestSeenMsgID = 0
+ }
}
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: flush before using entity in a foreign key column,
gnunet <=