From 2d3bb52bc8e442ccf9f924f6ccf6d2074185febd Mon Sep 17 00:00:00 2001 From: Halla Moore Date: Fri, 10 Feb 2017 15:22:27 -0800 Subject: [PATCH] [local-sync] Properly clean-up in-memory test database Summary: There's no file to unlink, we just need to drop the tables. Test Plan: manual Reviewers: evan, juan Reviewed By: evan, juan Differential Revision: https://phab.nylas.com/D3878 --- .../local-sync/src/shared/local-database-connector.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/local-sync/src/shared/local-database-connector.js b/packages/local-sync/src/shared/local-database-connector.js index 99459a9a6..6201532a7 100644 --- a/packages/local-sync/src/shared/local-database-connector.js +++ b/packages/local-sync/src/shared/local-database-connector.js @@ -65,6 +65,14 @@ class LocalDatabaseConnector { } destroyAccountDatabase(accountId) { + if (NylasEnv.inSpecMode()) { + // The db is in memory, so we don't have to unlink it. Just drop the data. + return this.forAccount(accountId).then(db => { + delete this._cache[accountId]; + return db.sequelize.drop() + }); + } + const dbname = `a-${accountId}`; const dbpath = path.join(process.env.NYLAS_HOME, `${dbname}.sqlite`); @@ -78,6 +86,7 @@ class LocalDatabaseConnector { } delete this._cache[accountId]; + return Promise.resolve(); } _sequelizeForShared() {