From 0a61d740ba0887006578d099cacd0443f8cf7de6 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Wed, 11 May 2022 16:05:16 -0400 Subject: [PATCH] (core) clear redis state for docapi tests Summary: DocApi tests occasionally fail in a confusing way due to redis state. This resets the redis state at the beginning of the test. Test Plan: existing tests pass Reviewers: alexmojaki Reviewed By: alexmojaki Subscribers: alexmojaki Differential Revision: https://phab.getgrist.com/D3424 --- test/server/lib/DocApi.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/server/lib/DocApi.ts b/test/server/lib/DocApi.ts index a341a791..2fbea761 100644 --- a/test/server/lib/DocApi.ts +++ b/test/server/lib/DocApi.ts @@ -67,6 +67,13 @@ describe('DocApi', function() { const oldEnv = clone(process.env); before(async function() { + // Clear redis test database if redis is in use. + if (process.env.TEST_REDIS_URL) { + const cli = createClient(process.env.TEST_REDIS_URL); + await cli.flushdbAsync(); + await cli.quitAsync(); + } + // Create the tmp dir removing any previous one await fse.remove(tmpDir); await fse.mkdirs(tmpDir);