feat(backend): ThtRunner wrapper for tht --json (sessions, sql preview/export)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 20:59:58 +02:00
co-authored by Claude Sonnet 4.6
parent 2d680c958c
commit c680060bd9
2 changed files with 100 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import { test, expect } from "vitest";
import { ThtRunner } from "../src/tht/tht-runner.js";
test("sessionNew parses id from JSON", async () => {
const r = new ThtRunner({ thtBin: "tht", harnessDir: "/h", configPath: "config/tht.yaml" });
r.run = async () => ({ code: 0, stdout: '{"id":"2026-06-27-100000-x"}', stderr: "" });
expect(await r.sessionNew({ question: "q" })).toEqual({ id: "2026-06-27-100000-x" });
});
test("run with exit != 0 propagates error with stderr", async () => {
const r = new ThtRunner({ thtBin: "tht", harnessDir: "/h", configPath: "config/tht.yaml" });
r.run = async () => ({ code: 1, stdout: "", stderr: "ERRORE: boom" });
await expect(r.sessionList()).rejects.toThrow(/boom/);
});