1import { Duration, Effect, Schedule } from "effect"
2import { sqlCleanupBatchSize } from "effect/internal/persistence"
3import { TestClock } from "effect/testing"
4
5export const expiredEntryCount = sqlCleanupBatchSize + 1
6export const expiredAtEpoch = 0
7export const futureExpiresAt = Number.MAX_SAFE_INTEGER
8export const cleanupBatchDelay = Duration.millis(10)
9export const testTimeout = 30_000
10
11export const waitForCount = <E, R>(
12 effect: Effect.Effect<number, E, R>,
13 predicate: (count: number) => boolean
14) =>
15 effect.pipe(
16 Effect.repeat({
17 until: predicate,
18 schedule: Schedule.spaced(cleanupBatchDelay)
19 }),
20 Effect.timeout(Duration.millis(testTimeout)),
21 TestClock.withLive
22 )