Test gh at verify -b does not require auth
Thanks to @williammartin, this completes the PR by ensuring the actual feature this new logic was added for actually works as expected :D
This commit is contained in:
parent
8e3afe55df
commit
cc36d32a21
1 changed files with 31 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/cli/cli/v2/pkg/cmd/attestation/test"
|
||||
"github.com/cli/cli/v2/pkg/cmd/attestation/verification"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cli/cli/v2/pkg/httpmock"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
|
|
@ -237,6 +238,36 @@ func TestNewVerifyCmd(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestVerifyCmdAuthChecks(t *testing.T) {
|
||||
f := &cmdutil.Factory{}
|
||||
|
||||
t.Run("by default auth check is required", func(t *testing.T) {
|
||||
cmd := NewVerifyCmd(f, func(o *Options) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
// IsAuthCheckEnabled assumes commands under test are subcommands
|
||||
parent := &cobra.Command{Use: "root"}
|
||||
parent.AddCommand(cmd)
|
||||
|
||||
require.NoError(t, cmd.ParseFlags([]string{}))
|
||||
require.True(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check to be required")
|
||||
})
|
||||
|
||||
t.Run("when --bundle flag is provided, auth check is not required", func(t *testing.T) {
|
||||
cmd := NewVerifyCmd(f, func(o *Options) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
// IsAuthCheckEnabled assumes commands under test are subcommands
|
||||
parent := &cobra.Command{Use: "root"}
|
||||
parent.AddCommand(cmd)
|
||||
|
||||
require.NoError(t, cmd.ParseFlags([]string{"--bundle", "not-important"}))
|
||||
require.False(t, cmdutil.IsAuthCheckEnabled(cmd), "expected auth check not to be required due to --bundle flag")
|
||||
})
|
||||
}
|
||||
|
||||
func TestJSONOutput(t *testing.T) {
|
||||
testIO, _, out, _ := iostreams.Test()
|
||||
opts := Options{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue