From 6b4e91ca0b64cbddeb56d4cab8c592d335dab7ec Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 9 Sep 2022 16:49:51 -0300 Subject: [PATCH] [db] Assert that DB transaction gets rolled back when index update fails --- .../dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt b/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt index c39cbc96d..7dadd8031 100644 --- a/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt +++ b/libs/database/src/dbTest/java/org/fdroid/index/v1/IndexV1UpdaterTest.kt @@ -130,6 +130,11 @@ internal class IndexV1UpdaterTest : DbTest() { val result = indexUpdater.updateNewRepo(repo, "not the right fingerprint") assertIs(result) assertIs(result.e) + + // check that the DB transaction was rolled back and the DB wasn't changed + assertEquals(repo, repoDao.getRepository(repoId) ?: fail()) + assertEquals(0, appDao.countApps()) + assertEquals(0, versionDao.countAppVersions()) } @Test