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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * This file tests migration invariants from schema version 19 to the current
     6  * schema version.
     7  */
     9 ////////////////////////////////////////////////////////////////////////////////
    10 //// Globals
    12 const kGuidAnnotationName = "placesInternal/GUID";
    14 function getTotalGuidAnnotationsCount(aStorageConnection) {
    15   stmt = aStorageConnection.createStatement(
    16     "SELECT count(*) "
    17   + "FROM moz_items_annos a "
    18   + "JOIN moz_anno_attributes b ON a.anno_attribute_id = b.id "
    19   + "WHERE b.name = :attr_name"
    20   );
    21   try {
    22     stmt.params.attr_name = kGuidAnnotationName;
    23     do_check_true(stmt.executeStep());
    24     return stmt.getInt32(0);
    25   } finally {
    26     stmt.finalize();
    27   }
    28 }
    30 ////////////////////////////////////////////////////////////////////////////////
    31 //// Tests
    33 function run_test()
    34 {
    35   setPlacesDatabase("places_v19.sqlite");
    36   run_next_test();
    37 }
    39 add_test(function test_initial_state()
    40 {
    41   let dbFile = gProfD.clone();
    42   dbFile.append(kDBName);
    43   let db = Services.storage.openUnsharedDatabase(dbFile);
    45   // There should be an obsolete bookmark GUID annotation.
    46   do_check_eq(getTotalGuidAnnotationsCount(db), 1);
    48   // Check our schema version to make sure it is actually at 19.
    49   do_check_eq(db.schemaVersion, 19);
    51   db.close();
    52   run_next_test();
    53 });
    55 add_test(function test_bookmark_guid_annotation_removed()
    56 {
    58   // There should be no obsolete bookmark GUID annotation anymore.
    59   do_check_eq(getTotalGuidAnnotationsCount(DBConn()), 0);
    61   run_next_test();
    62 });

mercurial