Files
pipelines/internal/claude/export_test.go
T
alan 1de74f76bb Chat info: Session section with native id, resume command and export
The chat information sheet gains a Session section: the harness's native
session id (copy), harness, directory, a verified resume command (copy)
and Export conversation (Markdown), Export JSON and, for Claude Code,
Export native session (the JSONL transcript).

Server: chat_sessions rows carry resume_command and native_export; new
chat_export command builds Markdown/JSON from the same paged history
chat_messages serves (bounded at 8 MiB), refuses non-operator sessions.
App: exports go through the artifact file bridge (web download, share
sheet on phones).
2026-11-03 10:59:41 +00:00

38 lines
1.2 KiB
Go

package claude
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
func TestNativeExportReturnsTheSessionJSONL(t *testing.T) {
config := t.TempDir()
t.Setenv("CLAUDE_CONFIG_DIR", config)
id := "0b6f1c2e-1111-4222-8333-444455556666"
project := filepath.Join(config, "projects", "-work-a")
if err := os.MkdirAll(project, 0o755); err != nil {
t.Fatal(err)
}
body := `{"type":"user","uuid":"u1"}` + "\n" + `{"type":"assistant","uuid":"a1"}` + "\n"
if err := os.WriteFile(filepath.Join(project, id+".jsonl"), []byte(body), 0o600); err != nil {
t.Fatal(err)
}
chat := New(context.Background())
defer chat.Close()
file, err := chat.NativeExport(context.Background(), id)
if err != nil {
t.Fatal(err)
}
if file.Name != id+".jsonl" || file.Mime != "application/x-ndjson" || file.Content != body || file.Format != protocol.ChatExportNative {
t.Fatalf("native export = %+v", file)
}
if _, err := chat.NativeExport(context.Background(), "0b6f1c2e-1111-4222-8333-000000000000"); err == nil || !strings.Contains(err.Error(), "has not written a transcript") {
t.Fatalf("missing transcript error = %v", err)
}
}