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

Function TestToolsetsCommandsRenderJSON

internal/cli/tool_test.go:451–519  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

449}
450
451func TestToolsetsCommandsRenderJSON(t *testing.T) {
452 t.Parallel()
453
454 t.Run("Should render toolsets list json", func(t *testing.T) {
455 t.Parallel()
456
457 client := &stubClient{
458 listToolsetsFn: func(_ context.Context, query ToolQuery) (ToolsetsResponseRecord, error) {
459 if query.WorkspaceID != "ws-1" {
460 t.Fatalf("ListToolsets query = %#v, want ws-1", query)
461 }
462 return sampleToolsetsResponse(), nil
463 },
464 }
465 stdout, _, err := executeRootCommand(
466 t,
467 newTestDeps(t, client),
468 "toolsets",
469 "list",
470 "--workspace",
471 "ws-1",
472 "-o",
473 "json",
474 )
475 if err != nil {
476 t.Fatalf("toolsets list error = %v", err)
477 }
478 var response ToolsetsResponseRecord
479 decodeJSONOutput(t, stdout, &response)
480 if got, want := len(response.Toolsets), 2; got != want {
481 t.Fatalf("toolset count = %d, want %d", got, want)
482 }
483 if got, want := response.Toolsets[1].Status, "degraded"; got != want {
484 t.Fatalf("status = %q, want %q", got, want)
485 }
486 })
487
488 t.Run("Should render toolsets info json", func(t *testing.T) {
489 t.Parallel()
490
491 client := &stubClient{
492 getToolsetFn: func(_ context.Context, id string, query ToolQuery) (ToolsetResponseRecord, error) {
493 if id != toolspkg.ToolsetIDCatalog.String() || query.SessionID != "sess-1" {
494 t.Fatalf("GetToolset(%q, %#v), want catalog in sess-1", id, query)
495 }
496 return ToolsetResponseRecord{Toolset: sampleToolsetsResponse().Toolsets[0]}, nil
497 },
498 }
499 stdout, _, err := executeRootCommand(
500 t,
501 newTestDeps(t, client),
502 "toolsets",
503 "info",
504 toolspkg.ToolsetIDCatalog.String(),
505 "--session",
506 "sess-1",
507 "-o",
508 "json",

Callers

nothing calls this directly

Calls 6

sampleToolsetsResponseFunction · 0.85
executeRootCommandFunction · 0.85
newTestDepsFunction · 0.85
decodeJSONOutputFunction · 0.85
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected