(t *testing.T)
| 329 | } |
| 330 | |
| 331 | func 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 | |
| 362 | func TestRunOpenCmd_UnsupportedWithJSONOutput(t *testing.T) { |
| 363 | io, _, _, _ := iostreams.Test() |
nothing calls this directly
no test coverage detected