From cfe0f62dcca73c60229c0923810e0a1ba22fa8e5 Mon Sep 17 00:00:00 2001 From: Ling Samuel Date: Thu, 28 Jan 2021 16:06:09 +0800 Subject: [PATCH] Fix query cmd and test func name Signed-off-by: Ling Samuel --- cmd/kepctl/query.go | 2 +- pkg/kepctl/query_test.go | 41 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cmd/kepctl/query.go b/cmd/kepctl/query.go index f6382ef68dd..8954f4a647e 100644 --- a/cmd/kepctl/query.go +++ b/cmd/kepctl/query.go @@ -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) diff --git a/pkg/kepctl/query_test.go b/pkg/kepctl/query_test.go index d1a1c72470c..f3a8cf061e3 100644 --- a/pkg/kepctl/query_test.go +++ b/pkg/kepctl/query_test.go @@ -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]"), }, }