MCPcopy Create free account
hub / github.com/compozy/agh / TestCLIRoundTripIntegration

Function TestCLIRoundTripIntegration

internal/cli/cli_integration_test.go:45–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43)
44
45func TestCLIRoundTripIntegration(t *testing.T) {
46 t.Parallel()
47
48 h := newIntegrationHarness(t)
49
50 startOut, _, err := executeRootCommand(t, h.deps, "daemon", "start", "-o", "json")
51 if err != nil {
52 t.Fatalf("daemon start error = %v", err)
53 }
54 var started DaemonStatus
55 if err := json.Unmarshal([]byte(startOut), &started); err != nil {
56 t.Fatalf("json.Unmarshal(start) error = %v", err)
57 }
58 if started.Status != "running" {
59 t.Fatalf("start status = %q, want %q", started.Status, "running")
60 }
61
62 newOut, _, err := executeRootCommand(
63 t,
64 h.deps,
65 "session",
66 "new",
67 "--agent",
68 "coder",
69 "--name",
70 "demo",
71 "--cwd",
72 h.workspace,
73 "-o",
74 "json",
75 )
76 if err != nil {
77 t.Fatalf("session new error = %v", err)
78 }
79 var created SessionRecord
80 if err := json.Unmarshal([]byte(newOut), &created); err != nil {
81 t.Fatalf("json.Unmarshal(session new) error = %v", err)
82 }
83 if created.ID == "" {
84 t.Fatal("expected created session id")
85 }
86
87 promptOut, _, err := executeRootCommand(t, h.deps, "session", "prompt", created.ID, "hello", "-o", "json")
88 if err != nil {
89 t.Fatalf("session prompt error = %v", err)
90 }
91 var promptEvents []AgentEventRecord
92 if err := json.Unmarshal([]byte(promptOut), &promptEvents); err != nil {
93 t.Fatalf("json.Unmarshal(prompt) error = %v", err)
94 }
95 if len(promptEvents) < 2 {
96 t.Fatalf("prompt events = %d, want at least 2", len(promptEvents))
97 }
98
99 eventsOut, _, err := executeRootCommand(t, h.deps, "session", "events", created.ID, "-o", "json")
100 if err != nil {
101 t.Fatalf("session events error = %v", err)
102 }

Callers

nothing calls this directly

Calls 3

newIntegrationHarnessFunction · 0.85
executeRootCommandFunction · 0.85
waitForExitMethod · 0.45

Tested by

no test coverage detected