Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query cmd opts.Validate and test func name #2357

Merged
merged 1 commit into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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