Skip to content

Commit

Permalink
test creation strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jun 4, 2024
1 parent f62c8f7 commit 8c59f26
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/effect/test/Pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,35 @@ describe("Pool", () => {
expect(max).toBe(10)
}))

it.scoped("max pool size creation strategy", () =>
Effect.gen(function*($) {
const invalidated = yield* $(Ref.make(0))
const acquire = Effect.acquireRelease(
Effect.succeed("resource"),
() => Ref.update(invalidated, (n) => n + 1)
)
const pool = yield* $(Pool.makeWithTTL({
acquire,
min: 10,
max: 15,
timeToLive: Duration.seconds(60),
timeToLiveStrategy: "creation"
}))
const scope = yield* Scope.make()
yield* Pool.get(pool).pipe(
Effect.repeatN(14),
Scope.extend(scope)
)
const one = yield* $(Ref.get(invalidated))
yield* $(TestClock.adjust(Duration.seconds(60)))
const two = yield* $(Ref.get(invalidated))
yield* Scope.close(scope, Exit.void)
const three = yield* $(Ref.get(invalidated))
assert.strictEqual(one, 0)
assert.strictEqual(two, 0)
assert.strictEqual(three, 15)
}))

it.scoped("shutdown robustness", () =>
Effect.gen(function*($) {
const count = yield* $(Ref.make(0))
Expand Down

0 comments on commit 8c59f26

Please sign in to comment.