MCPcopy
hub / github.com/kubernetes/kubectl / TestNormalizationFuncGlobalExistence

Function TestNormalizationFuncGlobalExistence

pkg/cmd/cmd_test.go:33–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31)
32
33func TestNormalizationFuncGlobalExistence(t *testing.T) {
34 // This test can be safely deleted when we will not support multiple flag formats
35 root := NewKubectlCommand(KubectlOptions{IOStreams: genericiooptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr}})
36
37 if root.Parent() != nil {
38 t.Fatal("We expect the root command to be returned")
39 }
40 if root.GlobalNormalizationFunc() == nil {
41 t.Fatal("We expect that root command has a global normalization function")
42 }
43
44 if reflect.ValueOf(root.GlobalNormalizationFunc()).Pointer() != reflect.ValueOf(root.Flags().GetNormalizeFunc()).Pointer() {
45 t.Fatal("root command seems to have a wrong normalization function")
46 }
47
48 sub := root
49 for sub.HasSubCommands() {
50 sub = sub.Commands()[0]
51 }
52
53 // In case of failure of this test check this PR: spf13/cobra#110
54 if reflect.ValueOf(sub.Flags().GetNormalizeFunc()).Pointer() != reflect.ValueOf(root.Flags().GetNormalizeFunc()).Pointer() {
55 t.Fatal("child and root commands should have the same normalization functions")
56 }
57}
58
59func TestKubectlSubcommandShadowPlugin(t *testing.T) {
60 tests := []struct {

Callers

nothing calls this directly

Calls 1

NewKubectlCommandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…