Test backup: run every configured mechanism, stop misreporting passphrase-only as unconfigured
The user's report: with only a backup passphrase set (no S3), 'Test
backup nå' errored 'ikke konfigurert' even though Google Auto Backup
works on the passphrase alone. New runConfiguredBackups() writes the
Google blob whenever a passphrase exists and uploads to S3 only when
those credentials are present, throwing only when NOTHING is set up.
The toast now names what actually ran ('Kryptert Google-kopi
oppdatert' and/or the bucket key). Two instrumented tests pin both
ends: passphrase-only succeeds, nothing-configured throws.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c9ee76387f
commit
8e8156488a
3 changed files with 49 additions and 2 deletions
|
|
@ -86,6 +86,26 @@ class CloudBackupRoundTripTest {
|
|||
assertTrue("DB still empty after failed restore", db.inventoryDao().getAll().isEmpty())
|
||||
}
|
||||
|
||||
@Test fun testBackupWithOnlyPassphraseSucceeds() = runBlocking {
|
||||
// The user's report: passphrase set, no S3 → "Test backup" must NOT
|
||||
// error with "not configured"; it writes the Google blob and says so.
|
||||
SettingsStore(context).autoBackupPassphrase = "x"
|
||||
db.inventoryDao().insert(InventoryItem(name = "A", strength = "", unit = "stk", form = MedForm.OTHER))
|
||||
|
||||
val outcome = manager.runConfiguredBackups()
|
||||
assertTrue("cloud blob written", outcome.cloudBlobWritten)
|
||||
assertNull("no S3 attempted when unconfigured", outcome.s3Key)
|
||||
assertTrue(BackupManager.cloudBlobFile(context).exists())
|
||||
}
|
||||
|
||||
@Test fun testBackupWithNothingConfiguredThrows() = runBlocking {
|
||||
SettingsStore(context).autoBackupPassphrase = null
|
||||
try {
|
||||
manager.runConfiguredBackups()
|
||||
org.junit.Assert.fail("must require at least one mechanism")
|
||||
} catch (_: IllegalArgumentException) { /* expected */ }
|
||||
}
|
||||
|
||||
@Test fun noPassphraseRemovesBlob() = runBlocking {
|
||||
SettingsStore(context).autoBackupPassphrase = "x"
|
||||
db.inventoryDao().insert(InventoryItem(name = "A", strength = "", unit = "stk", form = MedForm.OTHER))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue