michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // This file tests migration from v1 to v2 michael@0: michael@0: function run_test() michael@0: { michael@0: // First import the downloads.sqlite file michael@0: importDatabaseFile("v1.sqlite"); michael@0: michael@0: // ok, now it is OK to init the download manager - this will perform the michael@0: // migration! michael@0: var dm = Cc["@mozilla.org/download-manager;1"]. michael@0: getService(Ci.nsIDownloadManager); michael@0: var dbConn = dm.DBConnection; michael@0: var stmt = null; michael@0: michael@0: // check schema version michael@0: do_check_true(dbConn.schemaVersion >= 2); michael@0: michael@0: // Check that the column no longer exists michael@0: try { michael@0: // throws when it doesn't exist michael@0: stmt = dbConn.createStatement("SELECT iconURL FROM moz_downloads"); michael@0: do_throw("should not get here"); michael@0: } catch (e) { michael@0: do_check_eq(Cr.NS_ERROR_FAILURE, e.result); michael@0: } michael@0: michael@0: // now we check the entries michael@0: stmt = dbConn.createStatement( michael@0: "SELECT name, source, target, startTime, endTime, state " + michael@0: "FROM moz_downloads " + michael@0: "WHERE id = 2"); michael@0: stmt.executeStep(); michael@0: do_check_eq("381603.patch", stmt.getString(0)); michael@0: do_check_eq("https://bugzilla.mozilla.org/attachment.cgi?id=266520", michael@0: stmt.getUTF8String(1)); michael@0: do_check_eq("file:///Users/sdwilsh/Desktop/381603.patch", michael@0: stmt.getUTF8String(2)); michael@0: do_check_eq(1180493839859230, stmt.getInt64(3)); michael@0: do_check_eq(1180493839859230, stmt.getInt64(4)); michael@0: do_check_eq(1, stmt.getInt32(5)); michael@0: stmt.finalize(); michael@0: michael@0: cleanup(); michael@0: } michael@0: