1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/migration/test_current_from_v19.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 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 invariants from schema version 19 to the current 1.9 + * schema version. 1.10 + */ 1.11 + 1.12 +//////////////////////////////////////////////////////////////////////////////// 1.13 +//// Globals 1.14 + 1.15 +const kGuidAnnotationName = "placesInternal/GUID"; 1.16 + 1.17 +function getTotalGuidAnnotationsCount(aStorageConnection) { 1.18 + stmt = aStorageConnection.createStatement( 1.19 + "SELECT count(*) " 1.20 + + "FROM moz_items_annos a " 1.21 + + "JOIN moz_anno_attributes b ON a.anno_attribute_id = b.id " 1.22 + + "WHERE b.name = :attr_name" 1.23 + ); 1.24 + try { 1.25 + stmt.params.attr_name = kGuidAnnotationName; 1.26 + do_check_true(stmt.executeStep()); 1.27 + return stmt.getInt32(0); 1.28 + } finally { 1.29 + stmt.finalize(); 1.30 + } 1.31 +} 1.32 + 1.33 +//////////////////////////////////////////////////////////////////////////////// 1.34 +//// Tests 1.35 + 1.36 +function run_test() 1.37 +{ 1.38 + setPlacesDatabase("places_v19.sqlite"); 1.39 + run_next_test(); 1.40 +} 1.41 + 1.42 +add_test(function test_initial_state() 1.43 +{ 1.44 + let dbFile = gProfD.clone(); 1.45 + dbFile.append(kDBName); 1.46 + let db = Services.storage.openUnsharedDatabase(dbFile); 1.47 + 1.48 + // There should be an obsolete bookmark GUID annotation. 1.49 + do_check_eq(getTotalGuidAnnotationsCount(db), 1); 1.50 + 1.51 + // Check our schema version to make sure it is actually at 19. 1.52 + do_check_eq(db.schemaVersion, 19); 1.53 + 1.54 + db.close(); 1.55 + run_next_test(); 1.56 +}); 1.57 + 1.58 +add_test(function test_bookmark_guid_annotation_removed() 1.59 +{ 1.60 + 1.61 + // There should be no obsolete bookmark GUID annotation anymore. 1.62 + do_check_eq(getTotalGuidAnnotationsCount(DBConn()), 0); 1.63 + 1.64 + run_next_test(); 1.65 +});