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

Function runTestCmd

pkg/cmd/crawler/test/test.go:91–134  ·  view source on GitHub ↗
(opts *TestOptions)

Source from the content-addressed store, hash-verified

89}
90
91func runTestCmd(opts *TestOptions) error {
92 if opts.DryRun {
93 summary := map[string]any{
94 "action": "test_crawler",
95 "id": opts.ID,
96 "url": opts.URL,
97 "config": opts.config,
98 "dryRun": true,
99 }
100
101 return cmdutil.PrintRunSummary(
102 opts.IO,
103 opts.PrintFlags,
104 summary,
105 fmt.Sprintf("Dry run: would test URL %s on crawler %s", opts.URL, opts.ID),
106 )
107 }
108
109 client, err := opts.CrawlerClient()
110 if err != nil {
111 return err
112 }
113 cs := opts.IO.ColorScheme()
114
115 opts.IO.StartProgressIndicatorWithLabel(
116 fmt.Sprintf("Testing URL %s on crawler %s", cs.Bold(opts.URL), cs.Bold(opts.ID)),
117 )
118 res, err := client.Test(opts.ID, opts.URL, opts.config)
119 if err != nil {
120 opts.IO.StopProgressIndicator()
121 return err
122 }
123 opts.IO.StopProgressIndicator()
124
125 p, err := opts.PrintFlags.ToPrinter()
126 if err != nil {
127 return err
128 }
129 if err := p.Print(opts.IO, res); err != nil {
130 return err
131 }
132
133 return nil
134}

Callers 1

NewTestCmdFunction · 0.85

Calls 8

PrintRunSummaryFunction · 0.92
ColorSchemeMethod · 0.80
BoldMethod · 0.80
TestMethod · 0.80
StopProgressIndicatorMethod · 0.80
PrintMethod · 0.65
ToPrinterMethod · 0.45

Tested by

no test coverage detected