Skip to content

Commit 963649d

Browse files
tps-embertps-anvil
authored andcommitted
task complete: 909a43d4-69df-4c28-9eab-f2934be5813e
1 parent b16d494 commit 963649d

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

packages/cli/test/agent-runtime-logs.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ describe("tps agent logs runtime tail", () => {
1111
let originalError: typeof console.error;
1212
let originalExit: typeof process.exit;
1313

14+
function writeSessionLog(agentId: string, content: string): void {
15+
const logDir = join(tempHome, ".tps", "agents", agentId);
16+
mkdirSync(logDir, { recursive: true });
17+
writeFileSync(join(logDir, "session.log"), content, "utf-8");
18+
}
19+
1420
beforeEach(() => {
1521
tempHome = mkdtempSync(join(tmpdir(), "tps-agent-runtime-logs-"));
1622
originalHome = process.env.HOME;
@@ -35,11 +41,9 @@ describe("tps agent logs runtime tail", () => {
3541
test("shows the last 50 lines by default", async () => {
3642
const { runAgent } = await import("../src/commands/agent.js");
3743
const output: string[] = [];
38-
mkdirSync(join(tempHome, ".tps", "logs"), { recursive: true });
39-
writeFileSync(
40-
join(tempHome, ".tps", "logs", "ember.log"),
44+
writeSessionLog(
45+
"ember",
4146
Array.from({ length: 60 }, (_, index) => `line-${index + 1}`).join("\n") + "\n",
42-
"utf-8",
4347
);
4448
process.stdout.write = ((chunk: string | Uint8Array) => {
4549
output.push(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf-8"));
@@ -56,11 +60,9 @@ describe("tps agent logs runtime tail", () => {
5660
test("respects a custom line count", async () => {
5761
const { runAgent } = await import("../src/commands/agent.js");
5862
const output: string[] = [];
59-
mkdirSync(join(tempHome, ".tps", "logs"), { recursive: true });
60-
writeFileSync(
61-
join(tempHome, ".tps", "logs", "ember.log"),
63+
writeSessionLog(
64+
"ember",
6265
["alpha", "beta", "gamma", "delta"].join("\n"),
63-
"utf-8",
6466
);
6567
process.stdout.write = ((chunk: string | Uint8Array) => {
6668
output.push(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf-8"));

0 commit comments

Comments
 (0)