From 7529a8fa7d2e0079a44a7534d8b7c3c994ac8ac2 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Thu, 2 Jul 2026 07:06:23 -0500 Subject: [PATCH] fix(test): correct AccountDataMigratorTest assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two on-device assertion failures (green on JVM compile, red on the emulator): - migratorDdlMatchesExportedAccountDatabaseSchema built its expected DDL by substituting the schema's `${TABLE_NAME}` placeholder with a backtick-wrapped name, but the exported createSql already wraps the placeholder in backticks — producing a double-backticked identifier that never matched the (correct, single-backticked) migrator DDL. Substitute the bare name so the guard compares like-for-like. - movesEveryAccountTableOutOfAPlaintextCache asserted signatureEnabled was false, but the seed row sets it to 1 (true). Assert the seeded values for both booleans so a true and a false each round-trip. The production migrator DDL and drop logic were already correct; only the tests were wrong. Co-Authored-By: Claude Fable 5 --- .../org/libremail/data/local/AccountDataMigratorTest.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt b/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt index 4eaf071..66e37d1 100644 --- a/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt +++ b/app/src/androidTest/kotlin/org/libremail/data/local/AccountDataMigratorTest.kt @@ -110,7 +110,9 @@ class AccountDataMigratorTest { assertEquals("smtp.example.org", account?.smtp?.host) assertEquals("sealed-secret", credentialDao().getById("acct")?.encryptedSecret) val settings = accountSettingsDao().get("acct") - assertEquals(false, settings?.signatureEnabled) + // Seeded signatureEnabled = 1, notificationsEnabled = 0: both booleans must round-trip. + assertEquals(true, settings?.signatureEnabled) + assertEquals(false, settings?.notificationsEnabled) assertEquals(6, settings?.retentionMonths) assertNull(settings?.retentionCount) val signatures = signatureDao().observeForAccount("acct").first() @@ -198,7 +200,7 @@ class AccountDataMigratorTest { for (i in 0 until entities.length()) { val entity = entities.getJSONObject(i) val table = entity.getString("tableName") - val expectedCreate = entity.getString("createSql").replace("\${TABLE_NAME}", "`$table`") + val expectedCreate = entity.getString("createSql").replace("\${TABLE_NAME}", table) assertEquals( "AccountDataMigrator DDL for `$table` must match the exported AccountDatabase schema", expectedCreate, @@ -211,7 +213,7 @@ class AccountDataMigratorTest { if (index.getString("name") == "index_signatures_accountId") { assertEquals( "AccountDataMigrator signatures index must match the exported schema", - index.getString("createSql").replace("\${TABLE_NAME}", "`$table`"), + index.getString("createSql").replace("\${TABLE_NAME}", table), AccountDataMigrator.SIGNATURES_INDEX_SQL, ) checkedIndex = true