Skip to content

Commit c144b26

Browse files
authored
Fix SQL cleanup test clock race (#6806)
1 parent c5bf174 commit c144b26

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

packages/sql/mysql2/test/Persistence.integration.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ it.layer(MysqlContainer.layerClient, { timeout: "30 seconds" })("Persistence SQL
5555
VALUES ('live', 'live', '{}', NULL), ('live', 'future', '{}', ${SqlCleanupTest.futureExpiresAt})
5656
`
5757

58-
yield* Layer.build(Persistence.layerBackingSql)
58+
yield* Layer.build(Persistence.layerBackingSql).pipe(TestClock.withLive)
5959

6060
let expired = yield* SqlCleanupTest.waitForCount(
6161
expiredCount,
@@ -65,7 +65,6 @@ it.layer(MysqlContainer.layerClient, { timeout: "30 seconds" })("Persistence SQL
6565

6666
while (expired > 0) {
6767
const previous = expired
68-
yield* TestClock.adjust(SqlCleanupTest.cleanupBatchDelay)
6968
expired = yield* SqlCleanupTest.waitForCount(expiredCount, (count) => count < previous)
7069
}
7170
assert.strictEqual(expired, 0)

packages/sql/pg/test/Persistence.integration.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ it.layer(PgContainer.layerClient, { timeout: "30 seconds" })("Persistence SQL cl
136136
VALUES ('live', 'live', '{}', NULL), ('live', 'future', '{}', ${SqlCleanupTest.futureExpiresAt})
137137
`
138138

139-
yield* Layer.build(Persistence.layerBackingSql)
139+
yield* Layer.build(Persistence.layerBackingSql).pipe(TestClock.withLive)
140140

141141
let expired = yield* SqlCleanupTest.waitForCount(
142142
expiredCount,
@@ -146,7 +146,6 @@ it.layer(PgContainer.layerClient, { timeout: "30 seconds" })("Persistence SQL cl
146146

147147
while (expired > 0) {
148148
const previous = expired
149-
yield* TestClock.adjust(SqlCleanupTest.cleanupBatchDelay)
150149
expired = yield* SqlCleanupTest.waitForCount(expiredCount, (count) => count < previous)
151150
}
152151
assert.strictEqual(expired, 0)

packages/sql/sqlite-node/test/Persistence.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ it.layer(ClientLayer)("Persistence SQL cleanup", (it) => {
139139
VALUES ('live', 'live', '{}', NULL), ('live', 'future', '{}', ${SqlCleanupTest.futureExpiresAt})
140140
`
141141

142-
yield* Layer.build(Persistence.layerBackingSql)
142+
yield* Layer.build(Persistence.layerBackingSql).pipe(TestClock.withLive)
143143

144144
let expired = yield* SqlCleanupTest.waitForCount(
145145
expiredCount,
@@ -149,7 +149,6 @@ it.layer(ClientLayer)("Persistence SQL cleanup", (it) => {
149149

150150
while (expired > 0) {
151151
const previous = expired
152-
yield* TestClock.adjust(SqlCleanupTest.cleanupBatchDelay)
153152
expired = yield* SqlCleanupTest.waitForCount(expiredCount, (count) => count < previous)
154153
}
155154
assert.strictEqual(expired, 0)

0 commit comments

Comments
 (0)