libeufin

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

commit dc723836229868294ea3bfdcaa76550e662bda23
parent 60119d3e5945a3ec2aea70e810d3e69f2bece4dc
Author: MS <ms@taler.net>
Date:   Sat, 27 Jun 2020 23:02:05 +0200

testing composite primary keys

Diffstat:
Mnexus/src/test/kotlin/DBTest.kt | 30++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/nexus/src/test/kotlin/DBTest.kt b/nexus/src/test/kotlin/DBTest.kt @@ -1,9 +1,7 @@ package tech.libeufin.nexus -import org.jetbrains.exposed.sql.Database -import org.jetbrains.exposed.sql.SchemaUtils -import org.jetbrains.exposed.sql.StdOutSqlLogger -import org.jetbrains.exposed.sql.addLogger +import org.jetbrains.exposed.exceptions.ExposedSQLException +import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.transactions.transaction import org.junit.Test import java.io.File @@ -32,8 +30,32 @@ fun withTestDatabase(f: () -> Unit) { } } +object MyTable : Table() { + val col1 = text("col1") + val col2 = text("col2") + override val primaryKey = PrimaryKey(col1, col2) +} class DBTest { + @Test(expected = ExposedSQLException::class) + fun sqlDslTest() { + withTestDatabase { + transaction { + addLogger(StdOutSqlLogger) + SchemaUtils.create(MyTable) + MyTable.insert { + it[col1] = "foo" + it[col2] = "bar" + } + // should throw ExposedSQLException + MyTable.insert { + it[col1] = "foo" + it[col2] = "bar" + } + } + } + } + @Test fun facadeConfigTest() { withTestDatabase {