37 const schemaSpec =
"chrome://songbird/content/library/localdatabase/schema.sql";
38 var
ioService =
Cc[
"@mozilla.org/network/io-service;1"]
39 .getService(
Ci.nsIIOService);
40 var schemaUri = ioService.newURI(schemaSpec,
null,
null);
41 var channel = ioService.newChannelFromURI(schemaUri);
42 var rawStream = channel.open();
43 var inStream =
Cc[
"@mozilla.org/scriptableinputstream;1"]
44 .createInstance(
Ci.nsIScriptableInputStream);
45 inStream.init(rawStream);
47 var
data =
"", buffer;
48 while ((buffer = inStream.read(~0))) {
54 const versionLineReg = /^
insert into library_metadata/;
55 for each (var line
in data.split(/\n/)) {
56 if (versionLineReg.test(line)) {
57 return parseInt(line.match(/
'(\d+)'/)[1]);
66 var databaseGUID =
"test_migration";
70 Cc[
"@songbirdnest.com/Songbird/Library/LocalDatabase/MigrationHelper;1"]
71 .createInstance(
Ci.sbILocalDatabaseMigrationHelper);
75 assertEqual(migrationHelper.getLatestSchemaVersion(),
77 "Error: Schema Version incorrect. Please ensure that the schema version in schema.sql matches the version in the Migration Helper!");
79 assertEqual(migrationHelper.canMigrate(1, 1000),
false);
80 assertEqual(migrationHelper.canMigrate(5, 6),
true);
function assertEqual(aExpected, aActual, aMessage)
function runTest()
Advanced DataRemote unit tests.
function insert(dbq, size, name)
function getLatestSchemaVersionFromFile()
Test file to ensure that the version information between the schema and the Migration Helper are the ...
function createLibrary(databaseGuid, databaseLocation)