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