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

Function TestRunOpenCmd_SingleShortcutJSONOutput

pkg/cmd/open/open_test.go:331–360  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

329}
330
331func TestRunOpenCmd_SingleShortcutJSONOutput(t *testing.T) {
332 io, _, stdout, _ := iostreams.Test()
333
334 cfg := test.NewConfigStubWithProfiles([]*config.Profile{
335 {Name: "default", ApplicationID: "APP123", APIKey: "key", Default: true},
336 })
337
338 opts, opened, authed := newTestOptions(io, cfg)
339 opts.Shortcut = "billing"
340 withOutputFormat(opts, "json")
341
342 err := runOpenCmd(opts)
343 require.NoError(t, err)
344
345 var entry pageEntry
346 require.NoError(t, json.Unmarshal(stdout.Bytes(), &entry))
347 assert.Equal(
348 t,
349 pageEntry{
350 Shortcut: "billing",
351 URL: "https://dashboard.algolia.com/account/billing/details?applicationId=APP123",
352 RequiresLogin: true,
353 },
354 entry,
355 )
356
357 // A dashboard target with --output does not sign in or open a browser.
358 assert.False(t, *authed)
359 assert.Empty(t, *opened)
360}
361
362func TestRunOpenCmd_UnsupportedWithJSONOutput(t *testing.T) {
363 io, _, _, _ := iostreams.Test()

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
newTestOptionsFunction · 0.85
withOutputFormatFunction · 0.85
runOpenCmdFunction · 0.85

Tested by

no test coverage detected