forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart-after-stop.test.ts
More file actions
33 lines (29 loc) · 1.08 KB
/
Copy pathrestart-after-stop.test.ts
File metadata and controls
33 lines (29 loc) · 1.08 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
import { describe, it, expect } from "vitest";
import { AgentRuntime } from "../../src/runtime/agent-runtime.js";
import { RuntimeError } from "../../src/errors/runtime-errors.js";
describe("AgentRuntime stop-then-restart rejection", () => {
it("throws RUNTIME_ALREADY_STOPPED when starting after stop", async () => {
const runtime = new AgentRuntime({ runtimeId: "restart-after-stop-test" });
await runtime.start();
await runtime.stop();
try {
await runtime.start();
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("RUNTIME_ALREADY_STOPPED");
expect(err.message).toContain("cannot be restarted");
}
});
it("RUNTIME_ALREADY_STARTED still works on double start", async () => {
const runtime = new AgentRuntime({ runtimeId: "double-start-verification" });
await runtime.start();
try {
await runtime.start();
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("RUNTIME_ALREADY_STARTED");
}
});
});