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

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:09d3bbb8f01a
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * This file tests migration invariants from schema version 19 to the current
6 * schema version.
7 */
8
9 ////////////////////////////////////////////////////////////////////////////////
10 //// Globals
11
12 const kGuidAnnotationName = "placesInternal/GUID";
13
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 }
29
30 ////////////////////////////////////////////////////////////////////////////////
31 //// Tests
32
33 function run_test()
34 {
35 setPlacesDatabase("places_v19.sqlite");
36 run_next_test();
37 }
38
39 add_test(function test_initial_state()
40 {
41 let dbFile = gProfD.clone();
42 dbFile.append(kDBName);
43 let db = Services.storage.openUnsharedDatabase(dbFile);
44
45 // There should be an obsolete bookmark GUID annotation.
46 do_check_eq(getTotalGuidAnnotationsCount(db), 1);
47
48 // Check our schema version to make sure it is actually at 19.
49 do_check_eq(db.schemaVersion, 19);
50
51 db.close();
52 run_next_test();
53 });
54
55 add_test(function test_bookmark_guid_annotation_removed()
56 {
57
58 // There should be no obsolete bookmark GUID annotation anymore.
59 do_check_eq(getTotalGuidAnnotationsCount(DBConn()), 0);
60
61 run_next_test();
62 });

mercurial