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

Function TestSessionListOutputFormatsIntegration

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

Source from the content-addressed store, hash-verified

138}
139
140func TestSessionListOutputFormatsIntegration(t *testing.T) {
141 t.Parallel()
142
143 h := newIntegrationHarness(t)
144 mustExecuteRoot(t, h.deps, "daemon", "start", "-o", "json")
145 defer func() {
146 if _, _, err := executeRootCommand(t, h.deps, "daemon", "stop", "-o", "json"); err != nil {
147 t.Fatalf("daemon stop error = %v", err)
148 }
149 if err := h.runner.waitForExit(); err != nil {
150 t.Fatalf("daemon runner wait error = %v", err)
151 }
152 }()
153
154 sessionOut, _, err := executeRootCommand(
155 t,
156 h.deps,
157 "session",
158 "new",
159 "--agent",
160 "coder",
161 "--name",
162 "demo",
163 "--cwd",
164 h.workspace,
165 "-o",
166 "json",
167 )
168 if err != nil {
169 t.Fatalf("session new error = %v", err)
170 }
171 var created SessionRecord
172 if err := json.Unmarshal([]byte(sessionOut), &created); err != nil {
173 t.Fatalf("json.Unmarshal(session new) error = %v", err)
174 }
175
176 humanOut, _, err := executeRootCommand(t, h.deps, "session", "list", "--all", "-o", "human")
177 if err != nil {
178 t.Fatalf("session list human error = %v", err)
179 }
180 if !strings.Contains(humanOut, "Sessions") || !strings.Contains(humanOut, created.ID) {
181 t.Fatalf("human output = %q, want session table", humanOut)
182 }
183
184 jsonOut, _, err := executeRootCommand(t, h.deps, "session", "list", "--all", "-o", "json")
185 if err != nil {
186 t.Fatalf("session list json error = %v", err)
187 }
188 var listed []SessionRecord
189 if err := json.Unmarshal([]byte(jsonOut), &listed); err != nil {
190 t.Fatalf("json.Unmarshal(session list) error = %v", err)
191 }
192 if len(listed) != 1 || listed[0].ID != created.ID {
193 t.Fatalf("listed = %#v, want one created session", listed)
194 }
195
196 toonOut, _, err := executeRootCommand(t, h.deps, "session", "list", "--all", "-o", "toon")
197 if err != nil {

Callers

nothing calls this directly

Calls 5

newIntegrationHarnessFunction · 0.85
mustExecuteRootFunction · 0.85
executeRootCommandFunction · 0.85
ContainsMethod · 0.80
waitForExitMethod · 0.45

Tested by

no test coverage detected