Skip to content

Commit

Permalink
Fix ScheduledActionService.executeBackup not checking the return valu…
Browse files Browse the repository at this point in the history
…e from the export task
  • Loading branch information
rivaldi8 committed Feb 26, 2018
1 parent cfce758 commit 131c534
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,14 @@ private static int executeBackup(ScheduledAction scheduledAction, SQLiteDatabase
Crashlytics.logException(e);
Log.e(LOG_TAG, e.getMessage());
}
Log.i(LOG_TAG, "Backup/export did not occur. There might have beeen no new transactions to export or it might have crashed");
if (!result) {
Log.i(LOG_TAG, "Backup/export did not occur. There might have been no"
+ " new transactions to export or it might have crashed");
// We don't know if something failed or there weren't transactions to export,
// so fall on the safe side and return as if something had failed.
// FIXME: Change ExportAsyncTask to distinguish between the two cases
return 0;
}
return 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ public void scheduledBackups_shouldNotRunBeforeNextScheduledExecution(){
}

/**
* Tests that an scheduled backup doesn't include transactions added or modified
* previous to the last run.
* Tests that a scheduled QIF backup isn't done when no transactions have
* been added or modified after the last run.
*/
@Test
public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun() {
Expand Down Expand Up @@ -422,8 +422,8 @@ public void scheduledBackups_shouldNotIncludeTransactionsPreviousToTheLastRun()
actions.add(scheduledBackup);
ScheduledActionService.processScheduledActions(actions, mDb);

assertThat(scheduledBackup.getExecutionCount()).isEqualTo(2);
assertThat(scheduledBackup.getLastRunTime()).isGreaterThan(previousLastRun);
assertThat(scheduledBackup.getExecutionCount()).isEqualTo(1);
assertThat(scheduledBackup.getLastRunTime()).isEqualTo(previousLastRun);
assertThat(backupFolder.listFiles()).hasSize(0);
}

Expand Down

0 comments on commit 131c534

Please sign in to comment.