Skip to content

Commit 1000474

Browse files
committed
improvement(tests): use the shared notLike operator in idempotency cleanup suite
1 parent edcd64c commit 1000474

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

apps/sim/lib/core/idempotency/cleanup.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22
* @vitest-environment node
33
*/
44
import { idempotencyKey } from '@sim/db/schema'
5-
import { dbChainMock, drizzleOrmMock, resetDbChainMock } from '@sim/testing'
6-
import { like } from 'drizzle-orm'
5+
import { dbChainMock, resetDbChainMock } from '@sim/testing'
6+
import { like, notLike } from 'drizzle-orm'
77
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest'
88

9-
const { mockNotLike } = vi.hoisted(() => ({
10-
mockNotLike: vi.fn((column: unknown, pattern: unknown) => ({ type: 'notLike', column, pattern })),
11-
}))
12-
139
vi.mock('@sim/db', () => dbChainMock)
14-
/** The shared operator mock has no `notLike`; extend it for this suite only. */
15-
vi.mock('drizzle-orm', () => ({ ...drizzleOrmMock, notLike: mockNotLike }))
1610
vi.mock('@sim/utils/helpers', () => ({ sleep: vi.fn() }))
1711

1812
import { cleanupExpiredIdempotencyKeys } from '@/lib/core/idempotency/cleanup'
@@ -28,19 +22,19 @@ describe('cleanupExpiredIdempotencyKeys', () => {
2822
it('retains irreversible admin credit-grant keys during global cleanup', async () => {
2923
await cleanupExpiredIdempotencyKeys()
3024

31-
expect(mockNotLike).toHaveBeenCalledWith(idempotencyKey.key, 'admin-credit-grant:%')
25+
expect(notLike).toHaveBeenCalledWith(idempotencyKey.key, 'admin-credit-grant:%')
3226
})
3327

3428
it('retains permanent workflow execution ID claims during global cleanup', async () => {
3529
await cleanupExpiredIdempotencyKeys()
3630

37-
expect(mockNotLike).toHaveBeenCalledWith(idempotencyKey.key, 'workflow-execution-id:%')
31+
expect(notLike).toHaveBeenCalledWith(idempotencyKey.key, 'workflow-execution-id:%')
3832
})
3933

4034
it('keeps explicit namespace cleanup behavior unchanged', async () => {
4135
await cleanupExpiredIdempotencyKeys({ namespace: 'webhook' })
4236

4337
expect(like).toHaveBeenCalledWith(idempotencyKey.key, 'webhook:%')
44-
expect(mockNotLike).not.toHaveBeenCalled()
38+
expect(notLike).not.toHaveBeenCalled()
4539
})
4640
})

0 commit comments

Comments
 (0)