Skip to content

Commit

Permalink
Merge pull request kubernetes#2357 from lingsamuel/fix-query-cmd
Browse files Browse the repository at this point in the history
Fix query cmd `opts.Validate` and test func name
  • Loading branch information
k8s-ci-robot authored Jan 30, 2021
2 parents dbc48e6 + cfe0f62 commit 7eb521c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cmd/kepctl/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func buildQueryCommand(k *kepctl.Client) *cobra.Command {
Long: "Query the local filesystem, and optionally GitHub PRs for KEPs",
Example: ` kepctl query --sig architecture --status provisional --include-prs`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate(args)
return opts.Validate()
},
RunE: func(cmd *cobra.Command, args []string) error {
return k.Query(opts)
Expand Down
41 changes: 20 additions & 21 deletions pkg/kepctl/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,47 @@ import (
"github.com/stretchr/testify/require"
)


func TestValidate(t *testing.T) {
func TestValidateQueryOpt(t *testing.T) {
testcases := []struct {
name string
queryOpts QueryOpts
err error
err error
}{
{
name: "Valid SIG",
queryOpts: QueryOpts{
CommonArgs: CommonArgs {
Name: "1011-test",
CommonArgs: CommonArgs{
Name: "1011-test",
},
SIG: []string{"sig-multicluster"},
IncludePRs: true,
Output: "json",
SIG: []string{"sig-multicluster"},
IncludePRs: true,
Output: "json",
},
err: nil,
err: nil,
},
{
name: "Invalid SIG",
queryOpts: QueryOpts{
CommonArgs: CommonArgs {
Name: "1011-test-xyz",
CommonArgs: CommonArgs{
Name: "1011-test-xyz",
},
SIG: []string{"sig-xyz"},
IncludePRs: true,
Output: "json",
SIG: []string{"sig-xyz"},
IncludePRs: true,
Output: "json",
},
err: fmt.Errorf("No SIG matches any of the passed regular expressions"),
err: fmt.Errorf("No SIG matches any of the passed regular expressions"),
},
{
name: "Unsupported Output format",
queryOpts: QueryOpts{
CommonArgs: CommonArgs {
Name: "1011-test-testing",
CommonArgs: CommonArgs{
Name: "1011-test-testing",
},
SIG: []string{"sig-testing"},
IncludePRs: true,
Output: "PDF",
SIG: []string{"sig-testing"},
IncludePRs: true,
Output: "PDF",
},
err: fmt.Errorf("unsupported output format: PDF. Valid values: [table json yaml]"),
err: fmt.Errorf("unsupported output format: PDF. Valid values: [table json yaml]"),
},
}

Expand Down

0 comments on commit 7eb521c

Please sign in to comment.