michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * This file tests migration invariants from schema version 19 to the current michael@0: * schema version. michael@0: */ michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// Globals michael@0: michael@0: const kGuidAnnotationName = "placesInternal/GUID"; michael@0: michael@0: function getTotalGuidAnnotationsCount(aStorageConnection) { michael@0: stmt = aStorageConnection.createStatement( michael@0: "SELECT count(*) " michael@0: + "FROM moz_items_annos a " michael@0: + "JOIN moz_anno_attributes b ON a.anno_attribute_id = b.id " michael@0: + "WHERE b.name = :attr_name" michael@0: ); michael@0: try { michael@0: stmt.params.attr_name = kGuidAnnotationName; michael@0: do_check_true(stmt.executeStep()); michael@0: return stmt.getInt32(0); michael@0: } finally { michael@0: stmt.finalize(); michael@0: } michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// Tests michael@0: michael@0: function run_test() michael@0: { michael@0: setPlacesDatabase("places_v19.sqlite"); michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_test(function test_initial_state() michael@0: { michael@0: let dbFile = gProfD.clone(); michael@0: dbFile.append(kDBName); michael@0: let db = Services.storage.openUnsharedDatabase(dbFile); michael@0: michael@0: // There should be an obsolete bookmark GUID annotation. michael@0: do_check_eq(getTotalGuidAnnotationsCount(db), 1); michael@0: michael@0: // Check our schema version to make sure it is actually at 19. michael@0: do_check_eq(db.schemaVersion, 19); michael@0: michael@0: db.close(); michael@0: run_next_test(); michael@0: }); michael@0: michael@0: add_test(function test_bookmark_guid_annotation_removed() michael@0: { michael@0: michael@0: // There should be no obsolete bookmark GUID annotation anymore. michael@0: do_check_eq(getTotalGuidAnnotationsCount(DBConn()), 0); michael@0: michael@0: run_next_test(); michael@0: });