aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-03-05 18:44:18 -0500
committerAllan Wang <me@allanwang.ca>2019-03-05 18:44:18 -0500
commitee9a9a696420d5da05b4f306898fff29e9abe1a4 (patch)
treea554d1f3de9dc06c53658e6075a560dfd753d015 /app/src
parentc917dc13dabe7781a097383ae89f2d00f32fffcb (diff)
downloadfrost-ee9a9a696420d5da05b4f306898fff29e9abe1a4.tar.gz
frost-ee9a9a696420d5da05b4f306898fff29e9abe1a4.tar.bz2
frost-ee9a9a696420d5da05b4f306898fff29e9abe1a4.zip
Create working dao without suspension
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt8
4 files changed, 14 insertions, 22 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt
index 6b68e804..2d94ed97 100644
--- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt
@@ -5,10 +5,11 @@ import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.runBlocking
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
+import org.junit.Rule
import org.junit.runner.RunWith
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
+import kotlin.test.Test
import kotlin.test.assertEquals
@RunWith(AndroidJUnit4::class)
@@ -16,9 +17,8 @@ class FrostDatabaseTest {
private lateinit var db: FrostDatabase
- @Before
+ @BeforeTest
fun before() {
-
val context = ApplicationProvider.getApplicationContext<Context>()
val privateDb = Room.inMemoryDatabaseBuilder(
context, FrostPrivateDatabase::class.java
@@ -29,7 +29,7 @@ class FrostDatabaseTest {
db = FrostDatabase(privateDb, publicDb)
}
- @After
+ @AfterTest
fun after() {
db.close()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index a7cd2777..ba92a345 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -44,7 +44,6 @@ import com.raizlabs.android.dbflow.config.DatabaseConfig
import com.raizlabs.android.dbflow.config.FlowConfig
import com.raizlabs.android.dbflow.config.FlowManager
import com.raizlabs.android.dbflow.runtime.ContentResolverNotifier
-import com.squareup.sqldelight.android.AndroidSqliteDriver
import java.util.Random
import kotlin.reflect.KClass
@@ -115,13 +114,6 @@ class FrostApp : Application() {
.thumbnail(old).into(imageView)
}
})
- val driver = AndroidSqliteDriver(Database.Schema, this, "test.db")
- val db = Database(driver)
- db.transaction {
- db.frostQueries.selectAll().executeAsList().forEach {
- it.id
- }
- }
if (BuildConfig.DEBUG)
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
override fun onActivityPaused(activity: Activity) {}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt
index 9deb57da..0b8283fd 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt
@@ -60,16 +60,16 @@ data class CookieEntity(
interface CookieDao {
@Query("SELECT * FROM cookies")
- suspend fun selectAll(): List<CookieEntity>
+ fun selectAll(): List<CookieEntity>
@Query("SELECT * FROM cookies WHERE id = :id")
- suspend fun selectById(id: Long): CookieEntity?
+ fun selectById(id: Long): CookieEntity?
@Insert(onConflict = OnConflictStrategy.REPLACE)
- suspend fun insertCookie(cookie: CookieEntity)
+ fun insertCookie(cookie: CookieEntity)
@Query("DELETE FROM cookies WHERE id = :id")
- suspend fun deleteById(id: Long)
+ fun deleteById(id: Long)
}
@Database(version = CookiesDb.VERSION)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt
index 2e2a9d62..ab01e025 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/db/FbTabsDb.kt
@@ -45,16 +45,16 @@ data class FbTabEntity(@androidx.room.PrimaryKey var position: Int, var tab: FbI
interface FbTabDao {
@Query("SELECT * FROM tabs ORDER BY position ASC")
- suspend fun _selectAll(): List<FbTabEntity>
+ fun _selectAll(): List<FbTabEntity>
@Query("DELETE FROM tabs")
- suspend fun _deleteAll()
+ fun _deleteAll()
@Insert(onConflict = OnConflictStrategy.REPLACE)
- suspend fun _insertAll(items: List<FbTabEntity>)
+ fun _insertAll(items: List<FbTabEntity>)
@Transaction
- suspend fun _save(items: List<FbTabEntity>) {
+ fun _save(items: List<FbTabEntity>) {
_deleteAll()
_insertAll(items)
}