Bug 718817 - Tests for deleted passwords database migration. r=dolske

This commit is contained in:
Wes Johnston 2012-02-09 09:56:03 -08:00
parent 7566c55a51
commit b46635199b
3 changed files with 32 additions and 1 deletions

View File

@ -14,7 +14,7 @@ const ENCTYPE_SDR = 1;
// Current schema version used by storage-mozStorage.js. This will need to be
// kept in sync with the version there (or else the tests fail).
const CURRENT_SCHEMA = 4;
const CURRENT_SCHEMA = 5;
function run_test() {
@ -294,6 +294,37 @@ do_check_true(LoginTest.is_about_now(t2.timeCreated));
do_check_true(LoginTest.is_about_now(t2.timeLastUsed));
do_check_true(LoginTest.is_about_now(t2.timePasswordChanged));
/* ========== 9 ========== */
testnum++;
testdesc = "Test upgrade from v4 storage"
LoginTest.copyFile("signons-v4.sqlite");
// Sanity check the test file.
dbConnection = LoginTest.openDB("signons-v4.sqlite");
do_check_eq(4, dbConnection.schemaVersion);
do_check_false(dbConnection.tableExists("moz_deleted_logins"));
storage = LoginTest.reloadStorage(OUTDIR, "signons-v4.sqlite");
do_check_eq(CURRENT_SCHEMA, dbConnection.schemaVersion);
do_check_true(dbConnection.tableExists("moz_deleted_logins"));
/* ========== 10 ========== */
testnum++;
testdesc = "Test upgrade from v4->v5->v4 storage"
LoginTest.copyFile("signons-v4v5.sqlite");
// Sanity check the test file.
dbConnection = LoginTest.openDB("signons-v4v5.sqlite");
do_check_eq(4, dbConnection.schemaVersion);
do_check_true(dbConnection.tableExists("moz_deleted_logins"));
storage = LoginTest.reloadStorage(OUTDIR, "signons-v4v5.sqlite");
do_check_eq(CURRENT_SCHEMA, dbConnection.schemaVersion);
do_check_true(dbConnection.tableExists("moz_deleted_logins"));
} catch (e) {
throw "FAILED in test #" + testnum + " -- " + testdesc + ": " + e;
}