libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 7529280def4b7d80c3a214fae97042a4c9848bc3
parent 2cd71ffab515a94e82f14b4dd28e7191cadef690
Author: MS <ms@taler.net>
Date:   Thu, 10 Dec 2020 16:46:44 +0100

need connection string to drop tables with command

Diffstat:
Mintegration-tests/util.py | 4++--
Mnexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 3++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 7++++---
Msandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt | 3++-
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 9++++-----
5 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/integration-tests/util.py b/integration-tests/util.py @@ -65,7 +65,7 @@ def dropSandboxTables(dbName): "-q", "--console=plain", "-p", "..", "sandbox:run", - f"--args=drop-tables --db-name={dbName}", + f"--args=drop-tables", ]) @@ -75,7 +75,7 @@ def dropNexusTables(dbName): "-q", "--console=plain", "-p", "..", "nexus:run", - f"--args=drop-tables --db-name={dbName}", + f"--args=drop-tables", ]) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt @@ -383,7 +383,8 @@ class NexusScheduledTaskEntity(id: EntityID<Int>) : IntEntity(id) { var prevScheduledExecutionSec by NexusScheduledTasksTable.prevScheduledExecutionSec } -fun dbDropTables() { +fun dbDropTables(dbConnectionString: String) { + Database.connect("$dbConnectionString") transaction { SchemaUtils.drop( NexusUsersTable, diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -51,12 +51,12 @@ class Serve : CliktCommand("Run nexus HTTP server") { helpFormatter = CliktHelpFormatter(showDefaultValues = true) } } - private val dbName by option().default("jdbc:sqlite://libeufindb") + private val dbConnString by option().default("jdbc:sqlite://libeufindb") private val host by option().default("127.0.0.1") private val logLevel by option() override fun run() { setLogLevel(logLevel) - serverMain(dbName, host) + serverMain(dbConnString, host) } } @@ -72,8 +72,9 @@ class ParseCamt : CliktCommand("Parse a camt file") { } class DropTables : CliktCommand("Drop all the tables from the database") { + private val dbConnString by option().default("jdbc:sqlite://libeufindb") override fun run() { - dbDropTables() + dbDropTables(dbConnString) } } diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt @@ -301,7 +301,8 @@ object BankAccountReportsTable : IntIdTable() { val bankAccount = reference("bankAccount", BankAccountsTable) } -fun dbDropTables() { +fun dbDropTables(dbConnectionString: String) { + Database.connect("${dbConnectionString}") transaction { SchemaUtils.drop( EbicsSubscribersTable, diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -60,8 +60,6 @@ import com.github.ajalt.clikt.core.subcommands import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option import io.ktor.request.* -import io.ktor.util.AttributeKey -import tech.libeufin.sandbox.BankAccountTransactionsTable import tech.libeufin.sandbox.BankAccountTransactionsTable.amount import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorBic import tech.libeufin.sandbox.BankAccountTransactionsTable.creditorIban @@ -93,18 +91,19 @@ class SandboxCommand : CliktCommand() { } class DropTables : CliktCommand("Drop all the tables from the database") { + private val dbConnString by option().default("jdbc:sqlite://libeufindb") override fun run() { - dbDropTables() + dbDropTables(dbConnString) } } class Serve : CliktCommand("Run sandbox HTTP server") { - private val dbName by option().default("jdbc:sqlite://libeufindb") + private val dbConnString by option().default("jdbc:sqlite://libeufindb") private val logLevel by option() override fun run() { LOGGER = LoggerFactory.getLogger("tech.libeufin.sandbox") setLogLevel(logLevel) - serverMain(dbName) + serverMain(dbConnString) } }