mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-13 23:52:06 +00:00
Use Effect timeout in compaction test (#26728)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, mock, test } from "bun:test"
|
||||
import { APICallError } from "ai"
|
||||
import { Cause, Effect, Exit, Layer, ManagedRuntime } from "effect"
|
||||
import { Cause, Deferred, Effect, Exit, Layer, ManagedRuntime } from "effect"
|
||||
import * as Stream from "effect/Stream"
|
||||
import z from "zod"
|
||||
import { Bus } from "../../src/bus"
|
||||
@@ -890,12 +890,12 @@ describe("session.compaction.process", () => {
|
||||
const session = yield* ssn.create({})
|
||||
const msg = yield* createUserMessage(session.id, "hello")
|
||||
const msgs = yield* ssn.messages({ sessionID: session.id })
|
||||
const done = defer()
|
||||
const done = yield* Deferred.make<void, Error>()
|
||||
let seen = false
|
||||
const unsub = yield* bus.subscribeCallback(SessionCompaction.Event.Compacted, (evt) => {
|
||||
if (evt.properties.sessionID !== session.id) return
|
||||
seen = true
|
||||
done.resolve()
|
||||
Deferred.doneUnsafe(done, Effect.void)
|
||||
})
|
||||
yield* Effect.addFinalizer(() => Effect.sync(unsub))
|
||||
|
||||
@@ -906,14 +906,7 @@ describe("session.compaction.process", () => {
|
||||
auto: false,
|
||||
})
|
||||
|
||||
yield* Effect.promise(() =>
|
||||
Promise.race([
|
||||
done.promise,
|
||||
wait(500).then(() => {
|
||||
throw new Error("timed out waiting for compacted event")
|
||||
}),
|
||||
]),
|
||||
)
|
||||
yield* Deferred.await(done).pipe(Effect.timeout("500 millis"))
|
||||
expect(result).toBe("continue")
|
||||
expect(seen).toBe(true)
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user