-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(*) make sure we enumerate all types in kumactl (#1673)
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com> (cherry picked from commit b02e60f)
- Loading branch information
Nikolay Nikolaev
authored and
mergify-bot
committed
Mar 11, 2021
1 parent
637cbb0
commit 7674506
Showing
8 changed files
with
239 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package get_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/kumahq/kuma/app/kumactl/cmd" | ||
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd" | ||
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1" | ||
core_store "github.com/kumahq/kuma/pkg/core/resources/store" | ||
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory" | ||
) | ||
|
||
func hasSubCommand(cmd *cobra.Command, sub string) bool { | ||
for _, c := range cmd.Commands() { | ||
if c.Use == sub { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
var _ = Describe("kumactl get ", func() { | ||
Describe("Get Command", func() { | ||
var rootCtx *kumactl_cmd.RootContext | ||
var rootCmd, getCmd *cobra.Command | ||
var store core_store.ResourceStore | ||
|
||
BeforeEach(func() { | ||
// setup | ||
rootCtx = kumactl_cmd.DefaultRootContext() | ||
rootCtx.Runtime.NewResourceStore = func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) { | ||
return store, nil | ||
} | ||
store = core_store.NewPaginationStore(memory_resources.NewStore()) | ||
|
||
rootCmd = cmd.NewRootCmd(rootCtx) | ||
for _, cmd := range rootCmd.Commands() { | ||
if cmd.Use == "get" { | ||
getCmd = cmd | ||
break | ||
} | ||
} | ||
Expect(getCmd).ToNot(BeNil()) | ||
}) | ||
|
||
It("should have get commands for all defined types", func() { | ||
// when | ||
Expect(len(getCmd.Commands()) > len(rootCtx.TypeArgs)).To(BeTrue()) | ||
|
||
// then | ||
for sub := range rootCtx.TypeArgs { | ||
Expect(hasSubCommand(getCmd, sub+" NAME")).To(BeTrue(), "failing to find "+sub) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.