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

Function TestJSONOutputProducesValidJSON

internal/cli/format_test.go:40–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestJSONOutputProducesValidJSON(t *testing.T) {
41 t.Parallel()
42
43 t.Run("Should produce valid JSON", func(t *testing.T) {
44 t.Parallel()
45
46 deps := newTestDeps(t, &stubClient{
47 listSessionsFn: func(_ context.Context, _ SessionListQuery) ([]SessionRecord, error) {
48 return []SessionRecord{{
49 ID: "sess-1",
50 Name: "demo",
51 AgentName: "coder",
52 WorkspaceID: "ws-1",
53 WorkspacePath: "/workspace/project",
54 State: "active",
55 CreatedAt: fixedTestNow.Add(-time.Minute),
56 UpdatedAt: fixedTestNow,
57 }}, nil
58 },
59 })
60
61 stdout, _, err := executeRootCommand(t, deps, "session", "list", "-o", "json")
62 if err != nil {
63 t.Fatalf("executeRootCommand() error = %v", err)
64 }
65
66 var decoded []SessionRecord
67 if err := json.Unmarshal([]byte(stdout), &decoded); err != nil {
68 t.Fatalf("json.Unmarshal() error = %v", err)
69 }
70 if len(decoded) != 1 || decoded[0].ID != "sess-1" {
71 t.Fatalf("decoded = %#v, want one session", decoded)
72 }
73 })
74}
75
76func TestToonOutputProducesToonDocument(t *testing.T) {
77 t.Parallel()

Callers

nothing calls this directly

Calls 4

newTestDepsFunction · 0.85
executeRootCommandFunction · 0.85
RunMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected