Skip to content
Source
Sign inSign up
Open History to see the last commit

triageSession.test.ts

33 lines1.2 KB

1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { assert, it } from "@effect/vitest";
3import * as Effect from "effect/Effect";
4import * as FileSystem from "effect/FileSystem";
5import * as Path from "effect/Path";
6​
7import packageJson from "../../package.json" with { type: "json" };
8import {
9 makePersistedServerRuntimeState,
10 persistServerRuntimeState,
11} from "../serverRuntimeState.ts";
12import { describeServerProcess } from "./triageSession.ts";
13​
14it.effect("reports the version the running server recorded, not the CLI's", () =>
15 Effect.gen(function* () {
16 const fs = yield* FileSystem.FileSystem;
17 const path = yield* Path.Path;
18 const statePath = path.join(
19 yield* fs.makeTempDirectoryScoped({ prefix: "t3-triage-" }),
20 "server-runtime.json",
21 );
22 const state = yield* makePersistedServerRuntimeState({
23 config: { host: undefined, devUrl: undefined },
24 port: 3773,
25 });
26 yield* persistServerRuntimeState({ path: statePath, state });
27​
28 assert.equal(
29 yield* describeServerProcess(statePath),
30 `running (pid ${String(process.pid)}, http://127.0.0.1:3773, version ${packageJson.version})`,
31 );
32 }).pipe(Effect.provide(NodeServices.layer)),
33);