cincue
09/04/2019, 2:30 PMEvan R.
09/04/2019, 8:41 PMExposedSQLException
cincue
09/05/2019, 3:43 PMEvan R.
09/05/2019, 4:02 PMobject MyTable : IntIdTable {
val name = varchar("name", 128)
}
You can use MockK to mock the “select” method, like:
mockkObject(MyTable)
every { MyTable.select(any()) } throws ExposedSQLException( /* Add params for exception here */ )
assertThrows(ExposedSQLException) { MyTable.select { MyTable.id eq 1 } }
// Use this to undo mock
unmockkObject(MyTable)
cincue
09/05/2019, 6:08 PMEvan R.
09/06/2019, 4:40 PMcincue
09/06/2019, 5:24 PMEvan R.
09/06/2019, 6:02 PM.select()
is an extension function. The following snippet worked for me:
mockkStatic("org.jetbrains.exposed.sql.QueriesKt")
every { MyTable.select(any<Op<Boolean>>()) } throws mockk<ExposedSQLException>()
assertThrows<ExposedSQLException> { MyTable.select { MyTable.id eq 5 } }
org.jetbrains.exposed.sql.Queries.kt
)cincue
09/10/2019, 5:06 PMEvan R.
09/11/2019, 3:41 PM