From fbac4d697705271f04c5355672caacf82907a578 Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sat, 9 Sep 2023 10:31:47 +0100 Subject: [PATCH] Allow failing by throwing an SQLiteException. Signed-off-by: Kenneth J. Shackleton --- .../src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt | 2 -- .../test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt b/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt index cf3899aa12..0e07d848da 100644 --- a/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt +++ b/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt @@ -48,7 +48,6 @@ import com.bloomberg.selekt.SQL_MISUSE import com.bloomberg.selekt.SQL_NOMEM import com.bloomberg.selekt.SQL_NOT_A_DATABASE import com.bloomberg.selekt.SQL_NOT_FOUND -import com.bloomberg.selekt.SQL_OK import com.bloomberg.selekt.SQL_RANGE import com.bloomberg.selekt.SQL_READONLY import com.bloomberg.selekt.SQL_TOO_BIG @@ -91,7 +90,6 @@ internal object SQLite : com.bloomberg.selekt.SQLite(sqlite) { message: String, context: String? ): Nothing { - require(code != SQL_OK) { "Result code is not an error: $code" } val exceptionMessage = extendedErrorMessage(code, extendedCode, message, context) throw when (code) { SQL_BUSY -> SQLiteDatabaseLockedException(exceptionMessage) diff --git a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt index 9950a7a8ca..0fe8e9af4c 100644 --- a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt +++ b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt @@ -16,7 +16,6 @@ package com.bloomberg.selekt.android -import android.database.SQLException import android.database.sqlite.SQLiteAbortException import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException import android.database.sqlite.SQLiteBlobTooBigException @@ -144,7 +143,7 @@ internal class SQLiteTest { @Test fun openThenRekeyWithoutKeyFails() { - assertFailsWith { + assertFailsWith { SQLite.rekey(db, otherKey) } } @@ -738,7 +737,7 @@ internal class SQLiteTest { @Test fun exceptionForErrorOk() { - assertFailsWith { + assertFailsWith { SQLite.throwSQLException(SQL_OK, SQL_OK, "") } }