Files
Agent-Native/runtime/session/jsonl_test.go
T
weichenandCursor fedf671a48
ci / vet-and-test (push) Successful in 5s
ci / docker-checkout-hostgateway (push) Successful in 3s
Import the current agent-native module as a fresh history.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-29 12:29:04 +00:00

39 lines
810 B
Go

package session
import (
"path/filepath"
"testing"
"agent-native/runtime/llm"
)
func TestAppendAndReplay(t *testing.T) {
path := filepath.Join(t.TempDir(), "transcript.jsonl")
st, err := Open(path)
if err != nil {
t.Fatal(err)
}
msgs := []llm.Message{
{Role: llm.RoleSystem, Content: "sys"},
{Role: llm.RoleUser, Content: "hi"},
{Role: llm.RoleAssistant, Content: "ok", StopReason: llm.StopEnd},
}
for _, m := range msgs {
if err := st.Append(m); err != nil {
t.Fatal(err)
}
}
got, err := st.Load()
if err != nil {
t.Fatal(err)
}
if len(got) != len(msgs) {
t.Fatalf("len %d", len(got))
}
for i := range msgs {
if got[i].Role != msgs[i].Role || got[i].Content != msgs[i].Content || got[i].StopReason != msgs[i].StopReason {
t.Fatalf("msg %d %#v", i, got[i])
}
}
}