Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435package daemon
import ( "encoding/json" "testing"
"albedo/cli/internal/daemon/protocol")
const shellFixture = `{"id":"01a0fcea-2b00-7000-8000-000000000001","command":"echo hi","status":"completed","exit_code":0,"output":"hi\n","output_bytes":3,"truncated":false,"error":null,"history_seq":42}`
func TestShellCommandStreamEventWireShape(t *testing.T) { got, err := decodeChatEvent(json.RawMessage(`{"type":"shell_command","sequence":8,"data":{"shell_command":` + shellFixture + `}}`)) if err != nil { t.Fatal(err) } if got.Type != EventShellCommand || got.ShellCommand == nil || got.ShellCommand.ID != "01a0fcea-2b00-7000-8000-000000000001" { t.Fatalf("decoded shell event: %#v", got) }}
func TestShellCommandCommittedHistoryPart(t *testing.T) { parts, err := decodeHistoryParts([]json.RawMessage{json.RawMessage(`{"kind":"json","field":"shell_command","value":` + shellFixture + `}`)}) if err != nil { t.Fatal(err) } events, err := historyEntryEvents(historyEntry{wire: protocol.HistoryEntry{ID: "entry-id", Position: 42, Kind: "shell_command"}, parts: parts}) if err != nil { t.Fatal(err) } if len(events) != 2 || events[0].Type != EventShellCommand || events[0].ShellCommand == nil || events[1].Type != EventCommitted { t.Fatalf("history projection: %#v", events) }}