Skip to content

Commit

Permalink
Fixed progress id issues. (#2255)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaskozmer authored Nov 17, 2023
1 parent 0068d01 commit 5d77dc8
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "a1cb353c4afbf14831de8752ace07ce9",
"identityHash": "1182046fc85ec1b16d7693e1a593081b",
"entities": [
{
"tableName": "AssignmentDueDateEntity",
Expand Down Expand Up @@ -5433,7 +5433,7 @@
},
{
"tableName": "FileSyncProgressEntity",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`fileId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `courseId` INTEGER NOT NULL, `fileName` TEXT NOT NULL, `progress` INTEGER NOT NULL, `fileSize` INTEGER NOT NULL, `additionalFile` INTEGER NOT NULL, `progressState` TEXT NOT NULL, FOREIGN KEY(`courseId`) REFERENCES `CourseSyncProgressEntity`(`courseId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`fileId` INTEGER NOT NULL, `courseId` INTEGER NOT NULL, `fileName` TEXT NOT NULL, `progress` INTEGER NOT NULL, `fileSize` INTEGER NOT NULL, `additionalFile` INTEGER NOT NULL, `progressState` TEXT NOT NULL, `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, FOREIGN KEY(`courseId`) REFERENCES `CourseSyncProgressEntity`(`courseId`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "fileId",
Expand Down Expand Up @@ -5476,12 +5476,18 @@
"columnName": "progressState",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"fileId"
"id"
]
},
"indices": [],
Expand All @@ -5503,7 +5509,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'a1cb353c4afbf14831de8752ace07ce9')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '1182046fc85ec1b16d7693e1a593081b')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
)
fileSyncProgressDao.insert(entity)

Expand All @@ -92,7 +93,8 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
)
fileSyncProgressDao.insertAll(listOf(entity))

Expand Down Expand Up @@ -143,15 +145,17 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
)
)
fileSyncProgressDao.insertAll(entities)
Expand All @@ -161,6 +165,33 @@ class FileSyncProgressDaoTest {
assertEquals(entities[0], result)
}

@Test
fun testFindById() = runTest {
val entities = listOf(
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 1",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 100L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 200L
)
)
fileSyncProgressDao.insertAll(entities)

val result = fileSyncProgressDao.findById(1L)

assertEquals(entities[0].copy(id = 1L), result)
}

@Test
fun testFindByFileIdLiveData() = runTest {
val entities = listOf(
Expand All @@ -170,15 +201,17 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
)
)
fileSyncProgressDao.insertAll(entities)
Expand All @@ -199,23 +232,26 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
),
FileSyncProgressEntity(
courseId = 2L,
fileName = "File 3",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 3L
fileId = 3L,
id = 3L
)
)
fileSyncProgressDao.insertAll(entities)
Expand All @@ -236,23 +272,26 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
),
FileSyncProgressEntity(
courseId = 2L,
fileName = "File 3",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 3L
fileId = 3L,
id = 3L
)
)
fileSyncProgressDao.insertAll(entities)
Expand Down Expand Up @@ -303,15 +342,17 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
),
FileSyncProgressEntity(
courseId = 1L,
Expand All @@ -320,7 +361,8 @@ class FileSyncProgressDaoTest {
fileSize = 1000L,
additionalFile = true,
progressState = ProgressState.IN_PROGRESS,
fileId = 3L
fileId = 3L,
id = 3L
),
FileSyncProgressEntity(
courseId = 1L,
Expand All @@ -329,7 +371,8 @@ class FileSyncProgressDaoTest {
fileSize = 0,
additionalFile = true,
progressState = ProgressState.IN_PROGRESS,
fileId = 4L
fileId = 4L,
id = 4L
)
)

Expand All @@ -350,15 +393,17 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
),
FileSyncProgressEntity(
courseId = 1L,
Expand All @@ -367,7 +412,8 @@ class FileSyncProgressDaoTest {
fileSize = 1000L,
additionalFile = true,
progressState = ProgressState.IN_PROGRESS,
fileId = 3L
fileId = 3L,
id = 3L
),
FileSyncProgressEntity(
courseId = 1L,
Expand All @@ -376,7 +422,8 @@ class FileSyncProgressDaoTest {
fileSize = 0,
additionalFile = true,
progressState = ProgressState.IN_PROGRESS,
fileId = 4L
fileId = 4L,
id = 4L
)
)

Expand All @@ -397,15 +444,17 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 1L
fileId = 1L,
id = 1L
),
FileSyncProgressEntity(
courseId = 1L,
fileName = "File 2",
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 2L
fileId = 2L,
id = 2L
)
)

Expand All @@ -417,7 +466,8 @@ class FileSyncProgressDaoTest {
progress = 0,
fileSize = 1000L,
progressState = ProgressState.IN_PROGRESS,
fileId = 3L
fileId = 3L,
id = 3L
)

val rowId = fileSyncProgressDao.insert(entity)
Expand Down
Loading

0 comments on commit 5d77dc8

Please sign in to comment.