mirror of
https://github.com/bitwarden/android.git
synced 2025-03-15 10:48:47 +03:00
Fix broken dao fake implementations (#420)
This commit is contained in:
parent
bf9845d7a0
commit
813b1a7a98
3 changed files with 18 additions and 9 deletions
|
@ -20,10 +20,12 @@ class FakeCiphersDao : CiphersDao {
|
|||
ciphersFlow.tryEmit(emptyList())
|
||||
}
|
||||
|
||||
override suspend fun deleteAllCiphers(userId: String) {
|
||||
override suspend fun deleteAllCiphers(userId: String): Int {
|
||||
deleteCiphersCalled = true
|
||||
val count = storedCiphers.count { it.userId == userId }
|
||||
storedCiphers.removeAll { it.userId == userId }
|
||||
ciphersFlow.tryEmit(storedCiphers.toList())
|
||||
return count
|
||||
}
|
||||
|
||||
override fun getAllCiphers(userId: String): Flow<List<CipherEntity>> =
|
||||
|
@ -34,9 +36,10 @@ class FakeCiphersDao : CiphersDao {
|
|||
ciphersFlow.tryEmit(ciphers.toList())
|
||||
}
|
||||
|
||||
override suspend fun replaceAllCiphers(userId: String, ciphers: List<CipherEntity>) {
|
||||
storedCiphers.removeAll { it.userId == userId }
|
||||
override suspend fun replaceAllCiphers(userId: String, ciphers: List<CipherEntity>): Boolean {
|
||||
val removed = storedCiphers.removeAll { it.userId == userId }
|
||||
storedCiphers.addAll(ciphers)
|
||||
ciphersFlow.tryEmit(ciphers.toList())
|
||||
return removed || ciphers.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ class FakeCollectionsDao : CollectionsDao {
|
|||
collectionsFlow.tryEmit(emptyList())
|
||||
}
|
||||
|
||||
override suspend fun deleteAllCollections(userId: String) {
|
||||
override suspend fun deleteAllCollections(userId: String): Int {
|
||||
deleteCollectionsCalled = true
|
||||
val count = storedCollections.count { it.userId == userId }
|
||||
storedCollections.removeAll { it.userId == userId }
|
||||
collectionsFlow.tryEmit(storedCollections.toList())
|
||||
return count
|
||||
}
|
||||
|
||||
override suspend fun deleteCollection(userId: String, collectionId: String) {
|
||||
|
@ -49,9 +51,10 @@ class FakeCollectionsDao : CollectionsDao {
|
|||
override suspend fun replaceAllCollections(
|
||||
userId: String,
|
||||
collections: List<CollectionEntity>,
|
||||
) {
|
||||
storedCollections.removeAll { it.userId == userId }
|
||||
): Boolean {
|
||||
val removed = storedCollections.removeAll { it.userId == userId }
|
||||
storedCollections.addAll(collections)
|
||||
collectionsFlow.tryEmit(storedCollections.toList())
|
||||
return removed || collections.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ class FakeFoldersDao : FoldersDao {
|
|||
foldersFlow.tryEmit(emptyList())
|
||||
}
|
||||
|
||||
override suspend fun deleteAllFolders(userId: String) {
|
||||
override suspend fun deleteAllFolders(userId: String): Int {
|
||||
deleteFoldersCalled = true
|
||||
val count = storedFolders.count { it.userId == userId }
|
||||
storedFolders.removeAll { it.userId == userId }
|
||||
foldersFlow.tryEmit(storedFolders.toList())
|
||||
return count
|
||||
}
|
||||
|
||||
override suspend fun deleteFolder(userId: String, folderId: String) {
|
||||
|
@ -46,9 +48,10 @@ class FakeFoldersDao : FoldersDao {
|
|||
foldersFlow.tryEmit(storedFolders.toList())
|
||||
}
|
||||
|
||||
override suspend fun replaceAllFolders(userId: String, folders: List<FolderEntity>) {
|
||||
storedFolders.removeAll { it.userId == userId }
|
||||
override suspend fun replaceAllFolders(userId: String, folders: List<FolderEntity>): Boolean {
|
||||
val removed = storedFolders.removeAll { it.userId == userId }
|
||||
storedFolders.addAll(folders)
|
||||
foldersFlow.tryEmit(storedFolders.toList())
|
||||
return removed || folders.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue