-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathOrchestrationReactor.test.ts
More file actions
74 lines (66 loc) · 2.47 KB
/
OrchestrationReactor.test.ts
File metadata and controls
74 lines (66 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Effect, Exit, Layer, ManagedRuntime, Scope } from "effect";
import { afterEach, describe, expect, it } from "vitest";
import { CheckpointReactor } from "../Services/CheckpointReactor.ts";
import { ProviderCommandReactor } from "../Services/ProviderCommandReactor.ts";
import { ProviderRuntimeIngestionService } from "../Services/ProviderRuntimeIngestion.ts";
import { OrchestrationReactor } from "../Services/OrchestrationReactor.ts";
import { QueuedFollowUpReactor } from "../Services/QueuedFollowUpReactor.ts";
import { makeOrchestrationReactor } from "./OrchestrationReactor.ts";
describe("OrchestrationReactor", () => {
let runtime: ManagedRuntime.ManagedRuntime<OrchestrationReactor, never> | null = null;
afterEach(async () => {
if (runtime) {
await runtime.dispose();
}
runtime = null;
});
it("starts provider ingestion, provider command, and checkpoint reactors", async () => {
const started: string[] = [];
runtime = ManagedRuntime.make(
Layer.effect(OrchestrationReactor, makeOrchestrationReactor).pipe(
Layer.provideMerge(
Layer.succeed(ProviderRuntimeIngestionService, {
start: Effect.sync(() => {
started.push("provider-runtime-ingestion");
}),
drain: Effect.void,
}),
),
Layer.provideMerge(
Layer.succeed(ProviderCommandReactor, {
start: Effect.sync(() => {
started.push("provider-command-reactor");
}),
drain: Effect.void,
}),
),
Layer.provideMerge(
Layer.succeed(CheckpointReactor, {
start: Effect.sync(() => {
started.push("checkpoint-reactor");
}),
drain: Effect.void,
}),
),
Layer.provideMerge(
Layer.succeed(QueuedFollowUpReactor, {
start: Effect.sync(() => {
started.push("queued-follow-up-reactor");
}),
drain: Effect.void,
}),
),
),
);
const reactor = await runtime.runPromise(Effect.service(OrchestrationReactor));
const scope = await Effect.runPromise(Scope.make("sequential"));
await Effect.runPromise(reactor.start.pipe(Scope.provide(scope)));
expect(started).toEqual([
"provider-runtime-ingestion",
"provider-command-reactor",
"checkpoint-reactor",
"queued-follow-up-reactor",
]);
await Effect.runPromise(Scope.close(scope, Exit.void));
});
});