gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 03/05: Testing #7515.


From: gnunet
Subject: [libeufin] 03/05: Testing #7515.
Date: Mon, 13 Mar 2023 10:25:14 +0100

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

commit 14c2af86551b402627923de5d49006ea1122afef
Author: MS <ms@taler.net>
AuthorDate: Mon Mar 13 10:06:35 2023 +0100

    Testing #7515.
---
 sandbox/src/test/kotlin/BalanceTest.kt | 21 +++++------
 sandbox/src/test/kotlin/DBTest.kt      | 67 +++++++++++++++++++++++-----------
 2 files changed, 55 insertions(+), 33 deletions(-)

diff --git a/sandbox/src/test/kotlin/BalanceTest.kt 
b/sandbox/src/test/kotlin/BalanceTest.kt
index 48497e98..cf9f3918 100644
--- a/sandbox/src/test/kotlin/BalanceTest.kt
+++ b/sandbox/src/test/kotlin/BalanceTest.kt
@@ -8,24 +8,21 @@ import java.math.BigDecimal
 import java.time.LocalDateTime
 
 class BalanceTest {
-
     @Test
     fun balanceTest() {
+        val config = DemobankConfig(
+            currency = "EUR",
+            bankDebtLimit = 1000000,
+            usersDebtLimit = 10000,
+            allowRegistrations = true,
+            demobankName = "default",
+            withSignupBonus = false
+        )
         withTestDatabase {
             transaction {
-                SchemaUtils.create(
-                    BankAccountsTable,
-                    BankAccountTransactionsTable,
-                    BankAccountFreshTransactionsTable,
-                    BankAccountStatementsTable
-                )
+                insertConfigPairs(config)
                 val demobank = DemobankConfigEntity.new {
-                    currency = "EUR"
-                    bankDebtLimit = 1000000
-                    usersDebtLimit = 10000
-                    allowRegistrations = true
                     name = "default"
-                    withSignupBonus = false
                 }
                 val one = BankAccountEntity.new {
                     iban = "IBAN 1"
diff --git a/sandbox/src/test/kotlin/DBTest.kt 
b/sandbox/src/test/kotlin/DBTest.kt
index c74ebce1..c63efd6f 100644
--- a/sandbox/src/test/kotlin/DBTest.kt
+++ b/sandbox/src/test/kotlin/DBTest.kt
@@ -30,47 +30,72 @@ import java.time.LocalDateTime
  * Cleans up the DB file afterwards.
  */
 fun withTestDatabase(f: () -> Unit) {
-    val dbfile = "jdbc:sqlite:/tmp/nexus-test.sqlite3"
-    File(dbfile).also {
+    val dbFile = "/tmp/sandbox-test.sqlite3"
+    val dbConn = "jdbc:sqlite:${dbFile}"
+    File(dbFile).also {
         if (it.exists()) {
             it.delete()
         }
     }
-    Database.connect("$dbfile")
-    dbDropTables(dbfile)
-    try {
-        f()
-    }
+    Database.connect(dbConn)
+    dbDropTables(dbConn)
+    dbCreateTables(dbConn)
+    try { f() }
     finally {
-        File(dbfile).also {
-            if (it.exists()) {
+        File(dbFile).also {
+            if (it.exists())
                 it.delete()
-            }
         }
     }
 }
 
 class DBTest {
+    private var config = DemobankConfig(
+        currency = "EUR",
+        bankDebtLimit = 1000000,
+        usersDebtLimit = 10000,
+        allowRegistrations = true,
+        demobankName = "default",
+        withSignupBonus = false,
+    )
+
+    /**
+     * Storing configuration values into the database,
+     * then extract them and check that they equal the
+     * configuration model object.
+     */
     @Test
-    fun exist() {
-        println("x")
+    fun insertPairsTest() {
+        withTestDatabase {
+            // Config model.
+            val config = DemobankConfig(
+                currency = "EUR",
+                bankDebtLimit = 1,
+                usersDebtLimit = 2,
+                allowRegistrations = true,
+                demobankName = "default",
+                withSignupBonus = true
+            )
+            transaction {
+                DemobankConfigEntity.new { name = "default" }
+                insertConfigPairs(config)
+                val db = getDefaultDemobank()
+                /**
+                 * db.config extracts config values from the database
+                 * and puts them in a fresh config model object.
+                 */
+                assert(config.hashCode() == db.config.hashCode())
+            }
+        }
     }
 
     @Test
     fun betweenDates() {
         withTestDatabase {
             transaction {
-                SchemaUtils.create(
-                    BankAccountTransactionsTable,
-                    BankAccountFreshTransactionsTable
-                )
+                insertConfigPairs(config)
                 val demobank = DemobankConfigEntity.new {
-                    currency = "EUR"
-                    bankDebtLimit = 1000000
-                    usersDebtLimit = 10000
-                    allowRegistrations = true
                     name = "default"
-                    withSignupBonus = false
                 }
                 val bankAccount = BankAccountEntity.new {
                     iban = "iban"

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]