MCPcopy Create free account
hub / github.com/Effect-TS/effect / assertTickerSurvives

Function assertTickerSurvives

packages/platform/node/test/RpcServer.test.ts:231–274  ·  view source on GitHub ↗
(
    setup: Effect.Effect<
      {
        readonly ticker: Stream.Stream<number, E>
        readonly failingCall: Effect.Effect<void>
      },
      never,
      R
    >,
    label: string
  )

Source from the content-addressed store, hash-verified

229 )
230
231 const assertTickerSurvives = <E, R>(
232 setup: Effect.Effect<
233 {
234 readonly ticker: Stream.Stream<number, E>
235 readonly failingCall: Effect.Effect<void>
236 },
237 never,
238 R
239 >,
240 label: string
241 ) =>
242 Effect.gen(function*() {
243 const { failingCall, ticker } = yield* setup
244
245 const received = yield* Ref.make<Array<number>>([])
246
247 const tickerFiber = yield* ticker.pipe(
248 Stream.runForEach((value) => Ref.update(received, (xs) => [...xs, value])),
249 Effect.forkChild
250 )
251
252 yield* Effect.retry(
253 Effect.flatMap(
254 Ref.get(received),
255 (xs) => xs.length >= 2 ? Effect.void : Effect.fail("not enough ticks yet")
256 ),
257 { schedule: Schedule.spaced("50 millis"), times: 200 }
258 )
259
260 const ticksBefore = (yield* Ref.get(received)).length
261 assert.isAtLeast(ticksBefore, 2)
262
263 yield* failingCall
264
265 yield* Effect.sleep("300 millis")
266
267 const ticksAfter = (yield* Ref.get(received)).length
268 const tickerStatus = tickerFiber.pollUnsafe()
269
270 yield* Fiber.interrupt(tickerFiber)
271
272 assert.isUndefined(tickerStatus, `Ticker stream must still be running after ${label}`)
273 assert.isAbove(ticksAfter, ticksBefore, `Ticker stream must keep emitting after ${label}`)
274 })
275
276 describe("unknown-tag isolation", () => {
277 const Ghost = Rpc.make("Ghost", {

Callers 1

RpcServer.test.tsFile · 0.85

Calls 8

pollUnsafeMethod · 0.80
makeMethod · 0.65
pipeMethod · 0.65
getMethod · 0.65
sleepMethod · 0.65
updateMethod · 0.45
failMethod · 0.45
interruptMethod · 0.45

Tested by

no test coverage detected