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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     5 // This file tests migration from v5 to v6
     7 function run_test()
     8 {
     9   // First import the downloads.sqlite file
    10   importDatabaseFile("v5.sqlite");
    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;
    18   // check schema version
    19   do_check_true(dbConn.schemaVersion >= 6);
    21   // Check that the columns exist (no throw) and entries are correct
    22   var stmt = dbConn.createStatement(
    23     "SELECT name, source, target, startTime, endTime, state, referrer, " +
    24            "entityID, tempPath, currBytes, maxBytes " +
    25     "FROM moz_downloads " +
    26     "WHERE id = 27");
    27   stmt.executeStep();
    28   do_check_eq("Firefox 2.0.0.6.dmg", stmt.getString(0));
    29   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",
    30               stmt.getUTF8String(1));
    31   do_check_eq("file:///Users/sdwilsh/Desktop/Firefox%202.0.0.6.dmg",
    32               stmt.getUTF8String(2));
    33   do_check_eq(1187390974170783, stmt.getInt64(3));
    34   do_check_eq(1187391001257446, stmt.getInt64(4));
    35   do_check_eq(1, stmt.getInt32(5));
    36   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));
    37   do_check_true(stmt.getIsNull(7));
    38   do_check_true(stmt.getIsNull(8));
    39   do_check_eq(0, stmt.getInt64(9));
    40   do_check_eq(-1, stmt.getInt64(10));
    41   stmt.finalize();
    43   cleanup();
    44 }

mercurial