Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

56 lines
1.6 KiB
Go

package agentsessionstore
import (
"context"
"testing"
)
type captureSessionReporter struct {
inputs []ReportSessionMessagesInput
}
func (*captureSessionReporter) ReportSessionState(context.Context, ReportSessionStateInput) (ReportSessionStateReply, error) {
return ReportSessionStateReply{}, nil
}
func (c *captureSessionReporter) ReportSessionMessages(_ context.Context, input ReportSessionMessagesInput) (ReportSessionMessagesReply, error) {
c.inputs = append(c.inputs, input)
return ReportSessionMessagesReply{AcceptedCount: len(input.Updates)}, nil
}
func TestMessageStreamWriterWritesDeltasAndTerminalStatus(t *testing.T) {
t.Parallel()
reporter := &captureSessionReporter{}
writer := NewMessageStreamWriter(
reporter,
"room-1",
"agent-session-1",
"message-1",
EventSource{Provider: "codex"},
)
if err := writer.Write(context.Background(), "hel"); err != nil {
t.Fatalf("Write(first): %v", err)
}
if err := writer.Write(context.Background(), "lo"); err != nil {
t.Fatalf("Write(second): %v", err)
}
if err := writer.Close(context.Background(), "completed"); err != nil {
t.Fatalf("Close: %v", err)
}
if len(reporter.inputs) != 3 {
t.Fatalf("reported input count = %d, want 3", len(reporter.inputs))
}
if got := reporter.inputs[0].Updates[0].ContentDelta; got != "hel" {
t.Fatalf("first delta = %q, want hel", got)
}
if got := reporter.inputs[1].Updates[0].ContentDelta; got != "lo" {
t.Fatalf("second delta = %q, want lo", got)
}
if got := reporter.inputs[2].Updates[0].Status; got != "completed" {
t.Fatalf("close status = %q, want completed", got)
}
}