From d6e848a81818c918e570a28d63139bf84cbfc93b Mon Sep 17 00:00:00 2001 From: Colin White Date: Wed, 13 Nov 2024 22:11:46 -0800 Subject: [PATCH] Add test to verify DiskLruCache entries persist deletion without flush. --- .../kotlin/coil3/disk/DiskLruCacheTest.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/coil-core/src/commonTest/kotlin/coil3/disk/DiskLruCacheTest.kt b/coil-core/src/commonTest/kotlin/coil3/disk/DiskLruCacheTest.kt index f02effc161..e0f129f328 100644 --- a/coil-core/src/commonTest/kotlin/coil3/disk/DiskLruCacheTest.kt +++ b/coil-core/src/commonTest/kotlin/coil3/disk/DiskLruCacheTest.kt @@ -1118,6 +1118,25 @@ class DiskLruCacheTest { assertEquals(0L, cache.size()) } + @Test + fun evictAllDeletesAllEntriesInJournalWithoutFlush() { + set("a", "a", "a") + set("b", "b", "b") + set("c", "c", "c") + + cache.evictAll() + assertAbsent("a") + assertAbsent("b") + assertAbsent("c") + assertEquals(0, cache.size()) + + createNewCache() + assertAbsent("a") + assertAbsent("b") + assertAbsent("c") + assertEquals(0, cache.size()) + } + @Test fun editSnapshotAfterEvictAllReturnsNullDueToStaleValue() { val expectedByteCount = 2L