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

Function newOpts

pkg/cmd/application/create/create_test.go:237–266  ·  view source on GitHub ↗

newOpts builds CreateOptions wired to the stub server, defaulting to JSON output.

(
	t *testing.T,
	srv *createServer,
	isTTY bool,
)

Source from the content-addressed store, hash-verified

235
236// newOpts builds CreateOptions wired to the stub server, defaulting to JSON output.
237func newOpts(
238 t *testing.T,
239 srv *createServer,
240 isTTY bool,
241) (*CreateOptions, *test.CmdInOut, *string) {
242 t.Helper()
243 seedToken(t)
244
245 f, out := test.NewFactory(isTTY, nil, nil, "")
246 opened := new(string)
247 opts := &CreateOptions{
248 IO: f.IOStreams,
249 Config: f.Config,
250 Name: "My First Application",
251 Region: "CA",
252 nameProvided: true,
253 PrintFlags: newPrintFlags("json"),
254 NewDashboardClient: func(string) *dashboard.Client {
255 c := dashboard.NewClientWithHTTPClient("test", srv.Client())
256 c.APIURL = srv.URL
257 c.DashboardURL = "https://dashboard.algolia.com"
258 return c
259 },
260 Browser: func(url string) error {
261 *opened = url
262 return nil
263 },
264 }
265 return opts, out, opened
266}
267
268func TestRun_FreeNonInteractive(t *testing.T) {
269 srv := newServer(t, `{"has_payment_method": false}`)

Calls 5

NewFactoryFunction · 0.92
NewClientWithHTTPClientFunction · 0.92
HelperMethod · 0.80
seedTokenFunction · 0.70
newPrintFlagsFunction · 0.70

Tested by

no test coverage detected