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

Function TestSupportBundleCommand

internal/cli/support_test.go:15–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestSupportBundleCommand(t *testing.T) {
16 t.Parallel()
17
18 t.Run("ShouldCreatePollAndDownloadThroughDaemon", func(t *testing.T) {
19 t.Parallel()
20
21 completedAt := fixedTestNow.Add(2 * time.Second)
22 outputDir := t.TempDir()
23 var createCalled bool
24 var getCalled bool
25 var downloadCalled bool
26 client := &stubClient{
27 createSupportBundleFn: func(_ context.Context, request CreateSupportBundleRequest) (SupportBundleOperationRecord, error) {
28 createCalled = true
29 if !request.Yes {
30 t.Fatalf("CreateSupportBundle() Yes = false, want true")
31 }
32 if request.IncludeStatus == nil || !*request.IncludeStatus {
33 t.Fatalf("CreateSupportBundle() IncludeStatus = %v, want true", request.IncludeStatus)
34 }
35 return SupportBundleOperationRecord{
36 OperationID: "op_123",
37 Status: "pending",
38 CreatedAt: fixedTestNow,
39 UpdatedAt: fixedTestNow,
40 }, nil
41 },
42 getSupportBundleFn: func(_ context.Context, operationID string) (SupportBundleOperationRecord, error) {
43 getCalled = true
44 if operationID != "op_123" {
45 t.Fatalf("GetSupportBundle() operationID = %q, want op_123", operationID)
46 }
47 return SupportBundleOperationRecord{
48 OperationID: "op_123",
49 Status: "completed",
50 FileName: "agh-support-bundle-20260520T120000Z.tar.gz",
51 SizeBytes: 12,
52 CreatedAt: fixedTestNow,
53 UpdatedAt: completedAt,
54 CompletedAt: &completedAt,
55 }, nil
56 },
57 downloadSupportBundleFn: func(_ context.Context, operationID string, dst io.Writer) error {
58 downloadCalled = true
59 if operationID != "op_123" {
60 t.Fatalf("DownloadSupportBundle() operationID = %q, want op_123", operationID)
61 }
62 if _, err := io.WriteString(dst, "bundle-bytes"); err != nil {
63 return err
64 }
65 return nil
66 },
67 }
68 deps := newTestDeps(t, client)
69 deps.pollInterval = time.Millisecond
70
71 stdout, stderr, err := executeRootCommand(
72 t,

Callers

nothing calls this directly

Calls 8

newTestDepsFunction · 0.85
executeRootCommandFunction · 0.85
newRootCommandFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
ReadFileMethod · 0.65
AddMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected