MCPcopy Create free account
hub / github.com/algolia/cli / Test_runUnblockCmd_dryRunJSON

Function Test_runUnblockCmd_dryRunJSON

pkg/cmd/crawler/unblock/unblock_test.go:62–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func Test_runUnblockCmd_dryRunJSON(t *testing.T) {
63 r := httpmock.Registry{}
64 r.Register(
65 httpmock.REST("GET", "api/1/crawlers/my-crawler"),
66 httpmock.JSONResponse(crawler.Crawler{
67 ID: "my-crawler",
68 Name: "My crawler",
69 BlockingTaskID: "task-123",
70 BlockingError: "crawler is blocked",
71 }),
72 )
73 defer r.Verify(t)
74
75 f, out := test.NewFactory(false, &r, nil, "")
76 cmd := NewUnblockCmd(f, nil)
77
78 out, err := test.Execute(cmd, "my-crawler --dry-run --output json", out)
79 if err != nil {
80 t.Fatal(err)
81 }
82
83 assert.Contains(t, out.String(), `"action":"unblock_crawler"`)
84 assert.Contains(t, out.String(), `"id":"my-crawler"`)
85 assert.Contains(t, out.String(), `"blockingError":"crawler is blocked"`)
86 assert.Contains(t, out.String(), `"dryRun":true`)
87}

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
NewFactoryFunction · 0.92
ExecuteFunction · 0.92
NewUnblockCmdFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected