Why: Allow consumers to download an immutable module revision without nested source checkouts or local path replacements. Evidence: SELF package tests and the prior canonical-path rejection are recorded in the Dev dependency-workspace task card; remote consumption is replayed against the committed candidate. Impact: Change the module identity and its Go imports while preserving API behavior. Existing historical submodule revisions remain buildable. Refs: Versioned dependencies U1/U3; feature/dependency-workspace
39 lines
848 B
Go
39 lines
848 B
Go
package session
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git-ssh.u1680832.nyat.app/weichen/Agent-Native.git/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])
|
|
}
|
|
}
|
|
}
|