Fixed warning about aborted connection in tests

refs https://github.com/TryGhost/Toolbox/issues/389

- if we enable warning logs in E2E tests, we get a bunch of error
  messages saying `ERROR Unhandled rejection: aborted` coming from the
  SQLite DB reset code
- specifically, it's coming from the line that resets the DB by copying
  the file
- this line was initially added because we would see random SQLite
  "malformed database" errors
- I have a feeling that was due to something else, but I can't be sure
- I'm also not sure how else we should shut the DB connection, as this
  is the recommended way but it throws an unhandled rejection
- this commit is a bit of a gamble because I'm not actually sure what
  was causing the problem, but it gets rid of the errors locally and
  doesn't regress on the random failures
This commit is contained in:
Daniel Lockyer 2022-08-31 11:37:54 +01:00 committed by Daniel Lockyer
parent f04666ef52
commit c2b399fc2c

View File

@ -48,7 +48,6 @@ module.exports.reset = async ({truncate} = {truncate: false}) => {
const filenameOrig = `${filename}-orig`;
if (dbInitialized) {
await db.knex.destroy();
await fs.copyFile(filenameOrig, filename);
} else {
await fs.remove(filename);