(t *testing.T)
| 318 | } |
| 319 | |
| 320 | func TestVerifyCmdAuthChecks(t *testing.T) { |
| 321 | f := &cmdutil.Factory{} |
| 322 | |
| 323 | t.Run("by default auth check is required", func(t *testing.T) { |
| 324 | cmd := NewVerifyCmd(f, func(o *Options) error { |
| 325 | return nil |
| 326 | }) |
| 327 | |
| 328 | // IsAuthCheckEnabled assumes commands under test are subcommands |
| 329 | parent := &cobra.Command{Use: "root"} |
| 330 | parent.AddCommand(cmd) |
| 331 | |
| 332 | require.NoError(t, cmd.ParseFlags([]string{})) |
| 333 | require.True(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check to be required") |
| 334 | }) |
| 335 | |
| 336 | t.Run("when --bundle flag is provided, auth check is not required", func(t *testing.T) { |
| 337 | cmd := NewVerifyCmd(f, func(o *Options) error { |
| 338 | return nil |
| 339 | }) |
| 340 | |
| 341 | // IsAuthCheckEnabled assumes commands under test are subcommands |
| 342 | parent := &cobra.Command{Use: "root"} |
| 343 | parent.AddCommand(cmd) |
| 344 | |
| 345 | require.NoError(t, cmd.ParseFlags([]string{"--bundle", "not-important"})) |
| 346 | require.False(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check not to be required due to --bundle flag") |
| 347 | }) |
| 348 | } |
| 349 | |
| 350 | func TestJSONOutput(t *testing.T) { |
| 351 | testIO, _, out, _ := iostreams.Test() |
nothing calls this directly
no test coverage detected