1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/downloads/test/schema_migration/test_migration_to_6.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +// This file tests migration from v5 to v6 1.9 + 1.10 +function run_test() 1.11 +{ 1.12 + // First import the downloads.sqlite file 1.13 + importDatabaseFile("v5.sqlite"); 1.14 + 1.15 + // ok, now it is OK to init the download manager - this will perform the 1.16 + // migration! 1.17 + var dm = Cc["@mozilla.org/download-manager;1"]. 1.18 + getService(Ci.nsIDownloadManager); 1.19 + var dbConn = dm.DBConnection; 1.20 + 1.21 + // check schema version 1.22 + do_check_true(dbConn.schemaVersion >= 6); 1.23 + 1.24 + // Check that the columns exist (no throw) and entries are correct 1.25 + var stmt = dbConn.createStatement( 1.26 + "SELECT name, source, target, startTime, endTime, state, referrer, " + 1.27 + "entityID, tempPath, currBytes, maxBytes " + 1.28 + "FROM moz_downloads " + 1.29 + "WHERE id = 27"); 1.30 + stmt.executeStep(); 1.31 + do_check_eq("Firefox 2.0.0.6.dmg", stmt.getString(0)); 1.32 + do_check_eq("http://ftp-mozilla.netscape.com/pub/mozilla.org/firefox/releases/2.0.0.6/mac/en-US/Firefox%202.0.0.6.dmg", 1.33 + stmt.getUTF8String(1)); 1.34 + do_check_eq("file:///Users/sdwilsh/Desktop/Firefox%202.0.0.6.dmg", 1.35 + stmt.getUTF8String(2)); 1.36 + do_check_eq(1187390974170783, stmt.getInt64(3)); 1.37 + do_check_eq(1187391001257446, stmt.getInt64(4)); 1.38 + do_check_eq(1, stmt.getInt32(5)); 1.39 + do_check_eq("http://www.mozilla.com/en-US/products/download.html?product=firefox-2.0.0.6&os=osx&lang=en-US",stmt.getUTF8String(6)); 1.40 + do_check_true(stmt.getIsNull(7)); 1.41 + do_check_true(stmt.getIsNull(8)); 1.42 + do_check_eq(0, stmt.getInt64(9)); 1.43 + do_check_eq(-1, stmt.getInt64(10)); 1.44 + stmt.finalize(); 1.45 + 1.46 + cleanup(); 1.47 +}