toolkit/components/places/tests/migration/test_database_from_alpha.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/migration/test_database_from_alpha.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * This file tests migration replaces the database if schema version < 6.
     1.9 + */
    1.10 +
    1.11 +add_test(function corrupt_database_not_exists() {
    1.12 +  let dbFile = gProfD.clone();
    1.13 +  dbFile.append("places.sqlite.corrupt");
    1.14 +  do_check_false(dbFile.exists());
    1.15 +  run_next_test();
    1.16 +});
    1.17 +
    1.18 +add_test(function database_is_valid() {
    1.19 +  do_check_eq(PlacesUtils.history.databaseStatus,
    1.20 +              PlacesUtils.history.DATABASE_STATUS_CORRUPT);
    1.21 +  do_check_eq(DBConn().schemaVersion, CURRENT_SCHEMA_VERSION);
    1.22 +  run_next_test();
    1.23 +});
    1.24 +
    1.25 +add_test(function corrupt_database_exists() {
    1.26 +  let dbFile = gProfD.clone();
    1.27 +  dbFile.append("places.sqlite.corrupt");
    1.28 +  do_check_true(dbFile.exists());
    1.29 +  run_next_test();
    1.30 +});
    1.31 +
    1.32 +function run_test()
    1.33 +{
    1.34 +  setPlacesDatabase("places_alpha.sqlite");
    1.35 +  run_next_test();
    1.36 +}
    1.37 +

mercurial