mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 03:17:03 +05:30
Use boolean for is_saved field
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
parent
740d9e432a
commit
ab3f112981
3 changed files with 9 additions and 9 deletions
|
@ -55,7 +55,7 @@ val TEST_POST = LobstersPost(
|
||||||
emptyList(),
|
emptyList(),
|
||||||
),
|
),
|
||||||
listOf("openbsd", "linux", "containers", "hack the planet", "no thanks"),
|
listOf("openbsd", "linux", "containers", "hack the planet", "no thanks"),
|
||||||
0,
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import dev.msfjarvis.lobsters.model.Submitter;
|
import dev.msfjarvis.lobsters.model.Submitter;
|
||||||
import java.lang.Integer;
|
import java.lang.Boolean;
|
||||||
import kotlin.collections.List;
|
import kotlin.collections.List;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS LobstersPost(
|
CREATE TABLE IF NOT EXISTS LobstersPost(
|
||||||
|
@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS LobstersPost(
|
||||||
comments_url TEXT NOT NULL,
|
comments_url TEXT NOT NULL,
|
||||||
submitter_user TEXT as Submitter NOT NULL,
|
submitter_user TEXT as Submitter NOT NULL,
|
||||||
tags TEXT as List<String> NOT NULL,
|
tags TEXT as List<String> NOT NULL,
|
||||||
is_saved INTEGER as Integer DEFAULT 0
|
is_saved INTEGER as Boolean DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
selectAllPosts:
|
selectAllPosts:
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SqlDelightQueriesTest {
|
||||||
postQueries.insertOrReplacePost(post)
|
postQueries.insertOrReplacePost(post)
|
||||||
|
|
||||||
// Create a new post and try replacing it
|
// Create a new post and try replacing it
|
||||||
val newPost = post.copy(is_saved = 1)
|
val newPost = post.copy(is_saved = true)
|
||||||
postQueries.insertOrReplacePost(newPost)
|
postQueries.insertOrReplacePost(newPost)
|
||||||
|
|
||||||
// Check post count
|
// Check post count
|
||||||
|
@ -66,7 +66,7 @@ class SqlDelightQueriesTest {
|
||||||
|
|
||||||
// Check if post is updated
|
// Check if post is updated
|
||||||
val postFromDb = postQueries.selectPost(post.short_id).executeAsOne()
|
val postFromDb = postQueries.selectPost(post.short_id).executeAsOne()
|
||||||
assertEquals(1, postFromDb.is_saved)
|
assertEquals(true, postFromDb.is_saved)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -109,7 +109,7 @@ class SqlDelightQueriesTest {
|
||||||
|
|
||||||
// Get the post and check if is_saved is true
|
// Get the post and check if is_saved is true
|
||||||
val postFromDB = postQueries.selectPost(post.short_id).executeAsOne()
|
val postFromDB = postQueries.selectPost(post.short_id).executeAsOne()
|
||||||
assertEquals(1, postFromDB.is_saved)
|
assertEquals(true, postFromDB.is_saved)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -121,13 +121,13 @@ class SqlDelightQueriesTest {
|
||||||
|
|
||||||
// Get the post and check if is_saved is true
|
// Get the post and check if is_saved is true
|
||||||
val postFromDB = postQueries.selectPost(post.short_id).executeAsOne()
|
val postFromDB = postQueries.selectPost(post.short_id).executeAsOne()
|
||||||
assertEquals(1, postFromDB.is_saved)
|
assertEquals(true, postFromDB.is_saved)
|
||||||
|
|
||||||
postQueries.removeSavedPost(post.short_id)
|
postQueries.removeSavedPost(post.short_id)
|
||||||
|
|
||||||
// Get the post and check if is_saved is false
|
// Get the post and check if is_saved is false
|
||||||
val updatedPostFromDB = postQueries.selectPost(post.short_id).executeAsOne()
|
val updatedPostFromDB = postQueries.selectPost(post.short_id).executeAsOne()
|
||||||
assertEquals(0, updatedPostFromDB.is_saved)
|
assertEquals(false, updatedPostFromDB.is_saved)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -190,7 +190,7 @@ class SqlDelightQueriesTest {
|
||||||
comments_url = "test_comments_url",
|
comments_url = "test_comments_url",
|
||||||
submitter_user = submitter,
|
submitter_user = submitter,
|
||||||
tags = listOf(),
|
tags = listOf(),
|
||||||
is_saved = 0
|
is_saved = false
|
||||||
)
|
)
|
||||||
|
|
||||||
posts.add(post)
|
posts.add(post)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue