diff --git a/packages/backend-core/src/redis/tests/redlockImpl.spec.ts b/packages/backend-core/src/redis/tests/redlockImpl.spec.ts index 567c160db2..0661b8f7cc 100644 --- a/packages/backend-core/src/redis/tests/redlockImpl.spec.ts +++ b/packages/backend-core/src/redis/tests/redlockImpl.spec.ts @@ -1,18 +1,8 @@ import { LockName, LockType } from "@budibase/types" import { doWithLock } from "../redlockImpl" import { DBTestConfiguration } from "../../../tests" -import { Duration } from "../../utils" describe("redlockImpl", () => { - beforeEach(() => { - jest.useFakeTimers() - }) - - afterEach(() => { - jest.runOnlyPendingTimers() - jest.useRealTimers() - }) - describe("doWithLock", () => { it("should execute the task and return the result", async () => { const mockTask = jest.fn().mockResolvedValue("mockResult") @@ -21,16 +11,14 @@ describe("redlockImpl", () => { const testOpts = { name: LockName.PERSIST_WRITETHROUGH, type: LockType.AUTO_EXTEND, - ttl: 30000, + ttl: 5, } // Call the function with the mock lock and task const config = new DBTestConfiguration() const result = await config.doInTenant(() => doWithLock(testOpts, async () => { - jest.advanceTimersByTime(Duration.fromSeconds(10).toMs()) - jest.advanceTimersByTime(Duration.fromSeconds(10).toMs()) - jest.advanceTimersByTime(Duration.fromSeconds(10).toMs()) + await new Promise(r => setTimeout(() => r(), 10)) return mockTask() }) )