MCPcopy Create free account
hub / github.com/diillson/chatcli / TestWriteJSONL

Function TestWriteJSONL

cli/agent/trajectory/trajectory_test.go:37–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestWriteJSONL(t *testing.T) {
38 msgs := []models.Message{
39 {Role: "user", Content: "hi"},
40 {Role: "assistant", Content: "hello"},
41 }
42 var sb strings.Builder
43 n, err := WriteJSONL(&sb, msgs)
44 if err != nil {
45 t.Fatal(err)
46 }
47 if n != 2 {
48 t.Errorf("expected 2 lines, got %d", n)
49 }
50 lines := strings.Split(strings.TrimSpace(sb.String()), "\n")
51 if len(lines) != 2 {
52 t.Fatalf("expected 2 JSONL lines, got %d", len(lines))
53 }
54 if !strings.HasPrefix(lines[0], `{"from":"human"`) {
55 t.Errorf("unexpected first line: %s", lines[0])
56 }
57}

Callers

nothing calls this directly

Calls 3

WriteJSONLFunction · 0.85
ErrorfMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected