From fef6ecc640cd74a57bf8d522f7fcd06d2ef9b91f Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 8 Mar 2024 10:36:18 -0300 Subject: [PATCH] Fix flakyness in SmallFileBackupIntegrationTest --- .../storage/backup/SmallFileBackupIntegrationTest.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/lib/src/test/java/org/calyxos/backup/storage/backup/SmallFileBackupIntegrationTest.kt b/storage/lib/src/test/java/org/calyxos/backup/storage/backup/SmallFileBackupIntegrationTest.kt index 4d8214e4..ce2a4a77 100644 --- a/storage/lib/src/test/java/org/calyxos/backup/storage/backup/SmallFileBackupIntegrationTest.kt +++ b/storage/lib/src/test/java/org/calyxos/backup/storage/backup/SmallFileBackupIntegrationTest.kt @@ -77,7 +77,6 @@ internal class SmallFileBackupIntegrationTest { val outputStream2 = ByteArrayOutputStream() val chunkId = Random.nextBytes(KEY_SIZE_BYTES) - val cachedChunk = CachedChunk(chunkId.toHexString(), 0, 181, 0) val cachedFile2 = file2.toCachedFile(listOf(chunkId.toHexString()), 1) val backupFile = file2.toBackupFile(cachedFile2.chunks, cachedFile2.zipIndex) @@ -93,7 +92,14 @@ internal class SmallFileBackupIntegrationTest { every { mac.doFinal(any()) } returns chunkId every { chunksCache.get(any()) } returns null every { storagePlugin.getChunkOutputStream(any()) } returns outputStream2 - every { chunksCache.insert(cachedChunk) } just Runs + every { + chunksCache.insert(match { cachedChunk -> + cachedChunk.id == chunkId.toHexString() && + cachedChunk.refCount == 0L && + cachedChunk.size <= outputStream2.size() && + cachedChunk.version == 0.toByte() + }) + } just Runs every { filesCache.upsert(match { it.copy(lastSeen = cachedFile2.lastSeen) == cachedFile2