aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest/kotlin/com/pitchedapps
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-03-05 19:13:57 -0500
committerAllan Wang <me@allanwang.ca>2019-03-05 19:13:57 -0500
commitb5d442ba3c86500b23d5bff8f1eb80ab51d1ccfa (patch)
tree28b296d8ce5d6217b55461aef850d96fa265fdf0 /app/src/androidTest/kotlin/com/pitchedapps
parent8841728780438444bf51f1a2c3b0d961e49908d2 (diff)
downloadfrost-b5d442ba3c86500b23d5bff8f1eb80ab51d1ccfa.tar.gz
frost-b5d442ba3c86500b23d5bff8f1eb80ab51d1ccfa.tar.bz2
frost-b5d442ba3c86500b23d5bff8f1eb80ab51d1ccfa.zip
Add more cookie db tests
Diffstat (limited to 'app/src/androidTest/kotlin/com/pitchedapps')
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt41
1 files changed, 39 insertions, 2 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 2d94ed97..dcc96c2d 100644
--- a/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/db/FrostDatabaseTest.kt
@@ -5,7 +5,6 @@ import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.runBlocking
-import org.junit.Rule
import org.junit.runner.RunWith
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
@@ -35,7 +34,7 @@ class FrostDatabaseTest {
}
@Test
- fun basic() {
+ fun basicCookie() {
val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
runBlocking {
db.cookieDao().insertCookie(cookie)
@@ -43,4 +42,42 @@ class FrostDatabaseTest {
assertEquals(listOf(cookie), cookies, "Cookie mismatch")
}
}
+
+ @Test
+ fun deleteCookie() {
+ val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
+
+ runBlocking {
+ db.cookieDao().insertCookie(cookie)
+ db.cookieDao().deleteById(cookie.id + 1)
+ assertEquals(
+ listOf(cookie),
+ db.cookieDao().selectAll(),
+ "Cookie list should be the same after inexistent deletion"
+ )
+ db.cookieDao().deleteById(cookie.id)
+ assertEquals(emptyList(), db.cookieDao().selectAll(), "Cookie list should be empty after deletion")
+ }
+ }
+
+ @Test
+ fun insertCookie() {
+ val cookie = CookieEntity(id = 1234L, name = "testName", cookie = "testCookie")
+ runBlocking {
+ db.cookieDao().insertCookie(cookie)
+ assertEquals(listOf(cookie), db.cookieDao().selectAll(), "Cookie insertion failed")
+ db.cookieDao().insertCookie(cookie.copy(name = "testName2"))
+ assertEquals(
+ listOf(cookie.copy(name = "testName2")),
+ db.cookieDao().selectAll(),
+ "Cookie replacement failed"
+ )
+ db.cookieDao().insertCookie(cookie.copy(id = 123L))
+ assertEquals(
+ setOf(cookie.copy(id = 123L), cookie.copy(name = "testName2")),
+ db.cookieDao().selectAll().toSet(),
+ "New cookie insertion failed"
+ )
+ }
+ }
} \ No newline at end of file