Add support function to reset the DB and a test that it works.

This commit is contained in:
Simon Kornblith 2015-03-09 14:25:49 -04:00
parent b6673511f7
commit c7c58f8343
5 changed files with 41 additions and 2 deletions

View file

@ -164,4 +164,15 @@ function getTestDataDirectory() {
resURI = Services.io.newURI("resource://zotero-unit-tests/data", null, null);
return Services.io.newURI(resource.resolveURI(resURI), null, null).
QueryInterface(Components.interfaces.nsIFileURL).file;
}
/**
* Resets the Zotero DB and restarts Zotero. Returns a promise resolved
* when this finishes.
*/
function resetDB() {
var db = Zotero.getZoteroDatabase();
return Zotero.reinit(function() {
db.remove(false);
});
}