toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/tests/unit_aus_update/cleanupSuccessLogsFIFO.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 + */
     1.8 +
     1.9 +function run_test() {
    1.10 +  setupTestCommon();
    1.11 +
    1.12 +  logTestInfo("testing update logs are first in first out deleted");
    1.13 +
    1.14 +  writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
    1.15 +  var patches = getLocalPatchString(null, null, null, null, null, null,
    1.16 +                                    STATE_PENDING);
    1.17 +  var updates = getLocalUpdateString(patches);
    1.18 +  writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
    1.19 +  writeStatusFile(STATE_SUCCEEDED);
    1.20 +
    1.21 +  var dir = getUpdatesDir();
    1.22 +  var log = dir.clone();
    1.23 +  log.append(FILE_LAST_LOG);
    1.24 +  writeFile(log, "Backup Update Log");
    1.25 +
    1.26 +  log = dir.clone();
    1.27 +  log.append(FILE_BACKUP_LOG);
    1.28 +  writeFile(log, "To Be Deleted Backup Update Log");
    1.29 +
    1.30 +  log = dir.clone();
    1.31 +  log.append("0");
    1.32 +  log.append(FILE_UPDATE_LOG);
    1.33 +  writeFile(log, "Last Update Log");
    1.34 +
    1.35 +  standardInit();
    1.36 +
    1.37 +  logTestInfo("testing " + log.path + " shouldn't exist");
    1.38 +  do_check_false(log.exists());
    1.39 +
    1.40 +  log = dir.clone();
    1.41 +  log.append(FILE_LAST_LOG);
    1.42 +  logTestInfo("testing " + log.path + " should exist");
    1.43 +  do_check_true(log.exists());
    1.44 +
    1.45 +  logTestInfo("testing " + log.path + " contents");
    1.46 +  do_check_eq(readFile(log), "Last Update Log");
    1.47 +
    1.48 +  log = dir.clone();
    1.49 +  log.append(FILE_BACKUP_LOG);
    1.50 +  logTestInfo("testing " + log.path + " should exist");
    1.51 +  do_check_true(log.exists());
    1.52 +
    1.53 +  logTestInfo("testing " + log.path + " contents (bug 470979)");
    1.54 +  do_check_eq(readFile(log), "Backup Update Log");
    1.55 +
    1.56 +  dir.append("0");
    1.57 +  logTestInfo("testing " + dir.path + " should exist (bug 512994)");
    1.58 +  do_check_true(dir.exists());
    1.59 +
    1.60 +  doTestFinish();
    1.61 +}

mercurial