1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/downloads/test/schema_migration/test_migration_to_4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 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 v3 to v4 1.9 + 1.10 +function run_test() 1.11 +{ 1.12 + // First import the downloads.sqlite file 1.13 + importDatabaseFile("v3.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 + var stmt = null; 1.21 + 1.22 + // check schema version 1.23 + do_check_true(dbConn.schemaVersion >= 4); 1.24 + 1.25 + // Check that the column exists (statement should not throw) 1.26 + stmt = dbConn.createStatement("SELECT entityID FROM moz_downloads"); 1.27 + stmt.finalize(); 1.28 + 1.29 + // now we check the entries 1.30 + stmt = dbConn.createStatement( 1.31 + "SELECT name, source, target, startTime, endTime, state, referrer, entityID " + 1.32 + "FROM moz_downloads " + 1.33 + "WHERE id = 27"); 1.34 + stmt.executeStep(); 1.35 + do_check_eq("Firefox 2.0.0.6.dmg", stmt.getString(0)); 1.36 + 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.37 + stmt.getUTF8String(1)); 1.38 + do_check_eq("file:///Users/sdwilsh/Desktop/Firefox%202.0.0.6.dmg", 1.39 + stmt.getUTF8String(2)); 1.40 + do_check_eq(1187390974170783, stmt.getInt64(3)); 1.41 + do_check_eq(1187391001257446, stmt.getInt64(4)); 1.42 + do_check_eq(1, stmt.getInt32(5)); 1.43 + 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.44 + do_check_true(stmt.getIsNull(7)); 1.45 + stmt.finalize(); 1.46 + 1.47 + cleanup(); 1.48 +} 1.49 +