From 9ff2e8212f6028e5babfe6b8a9923fe85b1e33a4 Mon Sep 17 00:00:00 2001 From: Matthew Keil Date: Sat, 20 Jan 2024 11:17:48 -0500 Subject: [PATCH] test: fix race condition (#90) * fix: race condition in unit test * chore: lint fix --- test/multithreading-test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/multithreading-test.js b/test/multithreading-test.js index 74e58d1..41f03c0 100644 --- a/test/multithreading-test.js +++ b/test/multithreading-test.js @@ -25,12 +25,13 @@ test('check multithreading flag works as expected', async function (t) { t.plan(9) const location = tempy.directory() const db1 = new ClassicLevel(location) - const db2 = new ClassicLevel(location) - - // check that must set multithreading flag on all instances await db1.open() t.is(db1.location, location) + + // check that must set multithreading flag on all instances + let db2 try { + db2 = new ClassicLevel(location) await db2.open({ multithreading: true }) } catch (err) { t.is(err.code, 'LEVEL_DATABASE_NOT_OPEN', 'second instance failed to open')