|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 // This file tests migration from v1 to v2 |
|
6 |
|
7 function run_test() |
|
8 { |
|
9 // First import the downloads.sqlite file |
|
10 importDatabaseFile("v2.sqlite"); |
|
11 |
|
12 // ok, now it is OK to init the download manager - this will perform the |
|
13 // migration! |
|
14 var dm = Cc["@mozilla.org/download-manager;1"]. |
|
15 getService(Ci.nsIDownloadManager); |
|
16 var dbConn = dm.DBConnection; |
|
17 var stmt = null; |
|
18 |
|
19 // check schema version |
|
20 do_check_true(dbConn.schemaVersion >= 3); |
|
21 |
|
22 // Check that the column exists (statement should not throw) |
|
23 stmt = dbConn.createStatement("SELECT referrer FROM moz_downloads"); |
|
24 stmt.finalize(); |
|
25 |
|
26 // now we check the entries |
|
27 stmt = dbConn.createStatement( |
|
28 "SELECT name, source, target, startTime, endTime, state, referrer " + |
|
29 "FROM moz_downloads " + |
|
30 "WHERE id = 2"); |
|
31 stmt.executeStep(); |
|
32 do_check_eq("381603.patch", stmt.getString(0)); |
|
33 do_check_eq("https://bugzilla.mozilla.org/attachment.cgi?id=266520", |
|
34 stmt.getUTF8String(1)); |
|
35 do_check_eq("file:///Users/sdwilsh/Desktop/381603.patch", |
|
36 stmt.getUTF8String(2)); |
|
37 do_check_eq(1180493839859230, stmt.getInt64(3)); |
|
38 do_check_eq(1180493839859230, stmt.getInt64(4)); |
|
39 do_check_eq(1, stmt.getInt32(5)); |
|
40 do_check_true(stmt.getIsNull(6)); |
|
41 stmt.finalize(); |
|
42 |
|
43 cleanup(); |
|
44 } |
|
45 |