Clean redlock test settings

This commit is contained in:
Adria Navarro 2023-11-30 12:02:47 +01:00
parent 57b4c08731
commit 25099ee28e
1 changed files with 2 additions and 13 deletions

View File

@ -13,13 +13,7 @@ async function getClient(
if (type === LockType.CUSTOM) {
return newRedlock(opts)
}
if (
env.isTest() &&
type !== LockType.TRY_ONCE &&
type !== LockType.AUTO_EXTEND
) {
return newRedlock(OPTIONS.TEST)
}
switch (type) {
case LockType.TRY_ONCE: {
return newRedlock(OPTIONS.TRY_ONCE)
@ -42,7 +36,7 @@ async function getClient(
}
}
const OPTIONS: Record<keyof typeof LockType | "TEST", Redlock.Options> = {
const OPTIONS: Record<keyof typeof LockType, Redlock.Options> = {
TRY_ONCE: {
// immediately throws an error if the lock is already held
retryCount: 0,
@ -50,11 +44,6 @@ const OPTIONS: Record<keyof typeof LockType | "TEST", Redlock.Options> = {
TRY_TWICE: {
retryCount: 1,
},
TEST: {
// higher retry count in unit tests
// due to high contention.
retryCount: 100,
},
DEFAULT: {
// the expected clock drift; for more details
// see http://redis.io/topics/distlock