mirror of
https://github.com/renovatebot/renovate.git
synced 2024-12-22 05:28:35 +00:00
f042ae4c9a
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
29 lines
781 B
TypeScript
29 lines
781 B
TypeScript
import { afterEach } from '@jest/globals';
|
|
import { acquireLock, getMutex } from './mutex';
|
|
|
|
describe('util/mutex', () => {
|
|
describe('getMutex', () => {
|
|
it('returns mutex with default namespace', () => {
|
|
expect(getMutex('test')).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe('acquireLock', () => {
|
|
afterEach(() => {
|
|
getMutex('test').release();
|
|
});
|
|
|
|
it('return lock function with default namespace', async () => {
|
|
await expect(acquireLock('test')).resolves.toBeFunction();
|
|
});
|
|
|
|
it('should lock if already used', async () => {
|
|
const mutex = getMutex('test');
|
|
const releaseLock = await acquireLock('test');
|
|
expect(mutex.isLocked()).toBeTrue();
|
|
releaseLock();
|
|
expect(mutex.isLocked()).toBeFalse();
|
|
});
|
|
});
|
|
});
|