Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal class RoomEnrolmentRecordLocalDataSource @Inject constructor(
}
}

override suspend fun delete(queries: List<SubjectQuery>) {
override suspend fun delete(queries: List<SubjectQuery>): Unit = withContext(dispatcherIO) {
Simber.i("[delete] Deleting subjects with queries: $queries", tag = ROOM_RECORDS_DB)
database.withTransaction {
queries.forEach { query ->
Expand All @@ -202,7 +202,7 @@ internal class RoomEnrolmentRecordLocalDataSource @Inject constructor(
}
}

override suspend fun deleteAll() {
override suspend fun deleteAll(): Unit = withContext(dispatcherIO) {
Simber.i("[deleteAll] Deleting all subjects.", tag = ROOM_RECORDS_DB)
subjectDao.deleteSubjects(queryBuilder.buildDeleteQuery(SubjectQuery()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1544,4 +1544,19 @@ class RoomEnrolmentRecordLocalDataSourceTest {

// Then: Exception expected
}

@Test
fun `delete all - should delete all subjects`() = runTest {
// Given
setupInitialData()
val initialCount = dataSource.count()

// When
dataSource.deleteAll()

// Then
val finalCount = dataSource.count()
assertThat(finalCount).isEqualTo(0)
assertThat(initialCount).isGreaterThan(0)
}
}