toolkit/components/downloads/test/schema_migration/test_migration_to_7.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:92dc2a8e9885
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 function run_test()
6 {
7 // We're testing migration to this version from one version below
8 var targetVersion = 7;
9
10 // First import the downloads.sqlite file
11 importDatabaseFile("v" + (targetVersion - 1) + ".sqlite");
12
13 // Init the download manager which will try migrating to the new version
14 var dm = Cc["@mozilla.org/download-manager;1"].
15 getService(Ci.nsIDownloadManager);
16 var dbConn = dm.DBConnection;
17
18 // Check schema version
19 do_check_true(dbConn.schemaVersion >= targetVersion);
20
21 // Make sure all the columns are there
22 var stmt = dbConn.createStatement(
23 "SELECT name, source, target, tempPath, startTime, endTime, state, " +
24 "referrer, entityID, currBytes, maxBytes, mimeType, " +
25 "preferredApplication, preferredAction " +
26 "FROM moz_downloads " +
27 "WHERE id = 28");
28 stmt.executeStep();
29
30 // This data is based on the original values in the table
31 var data = [
32 "firefox-3.0a9pre.en-US.linux-i686.tar.bz2",
33 "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/firefox-3.0a9pre.en-US.linux-i686.tar.bz2",
34 "file:///Users/Ed/Desktop/firefox-3.0a9pre.en-US.linux-i686.tar.bz2",
35 "/Users/Ed/Desktop/+EZWafFQ.bz2.part",
36 1192469856209164,
37 1192469877017396,
38 Ci.nsIDownloadManager.DOWNLOAD_FINISHED,
39 "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/",
40 "%2210e66c1-8a2d6b-9b33f380%22/9055595/Mon, 15 Oct 2007 11:45:34 GMT",
41 1210772,
42 9055595,
43 // For the new columns added, check for null or default values
44 true,
45 true,
46 0,
47 ];
48
49 // Make sure the values are correct after the migration
50 var i = 0;
51 do_check_eq(data[i], stmt.getString(i++));
52 do_check_eq(data[i], stmt.getUTF8String(i++));
53 do_check_eq(data[i], stmt.getUTF8String(i++));
54 do_check_eq(data[i], stmt.getString(i++));
55 do_check_eq(data[i], stmt.getInt64(i++));
56 do_check_eq(data[i], stmt.getInt64(i++));
57 do_check_eq(data[i], stmt.getInt32(i++));
58 do_check_eq(data[i], stmt.getUTF8String(i++));
59 do_check_eq(data[i], stmt.getUTF8String(i++));
60 do_check_eq(data[i], stmt.getInt64(i++));
61 do_check_eq(data[i], stmt.getInt64(i++));
62 do_check_eq(data[i], stmt.getIsNull(i++));
63 do_check_eq(data[i], stmt.getIsNull(i++));
64 do_check_eq(data[i], stmt.getInt32(i++));
65
66 stmt.reset();
67 stmt.finalize();
68
69 cleanup();
70 }

mercurial