Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/components/satchel/test/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  test_db_corrupt.js   Sprache: JAVA

 
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


var bakFile;

function run_test() {
  // ===== test init =====
  let testfile = do_get_file("formhistory_CORRUPT.sqlite");
  let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);

  // Cleanup from any previous tests or failures.
  let destFile = profileDir.clone();
  destFile.append("formhistory.sqlite");
  if (destFile.exists()) {
    destFile.remove(false);
  }

  bakFile = profileDir.clone();
  bakFile.append("formhistory.sqlite.corrupt");
  if (bakFile.exists()) {
    bakFile.remove(false);
  }

  testfile.copyTo(profileDir, "formhistory.sqlite");
  run_next_test();
}

add_test(function test_corruptFormHistoryDB_lazyCorruptInit1() {
  do_log_info("ensure FormHistory backs up a corrupt DB on initialization.");

  // DB init is done lazily so the DB shouldn't be created yet.
  Assert.ok(!bakFile.exists());
  // Doing any request to the DB should create it.
  countEntries(nullnull, run_next_test);
});

add_test(function test_corruptFormHistoryDB_lazyCorruptInit2() {
  Assert.ok(bakFile.exists());
  bakFile.remove(false);
  run_next_test();
});

add_test(function test_corruptFormHistoryDB_emptyInit() {
  do_log_info(
    "test that FormHistory initializes an empty DB in place of corrupt DB."
  );

  (async function () {
    let count = await FormHistory.count({});
    Assert.equal(count, 0);
    count = await FormHistory.count({ fieldname: "name-A", value: "value-A" });
    Assert.equal(count, 0);
    run_next_test();
  })().catch(_error => {
    do_throw("DB initialized after reading a corrupt DB file is not empty.");
  });
});

add_test(function test_corruptFormHistoryDB_addEntry() {
  do_log_info("test adding an entry to the empty DB.");

  updateEntry("add""name-A""value-A"function () {
    countEntries("name-A""value-A"function (count) {
      Assert.ok(count == 1);
      run_next_test();
    });
  });
});

add_test(function test_corruptFormHistoryDB_removeEntry() {
  do_log_info("test removing an entry to the empty DB.");

  updateEntry("remove""name-A""value-A"function () {
    countEntries("name-A""value-A"function (count) {
      Assert.ok(count == 0);
      run_next_test();
    });
  });
});

Messung V0.5
C=87 H=99 G=93

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.