Warn for every _ flag user or cmd defined
also renames all global _ flags to -
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
@@ -276,3 +277,29 @@ func ExamplePrintReplicationController() {
|
||||
// CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
|
||||
// foo foo someimage foo=bar 1
|
||||
}
|
||||
|
||||
func TestNormalizationFuncGlobalExistance(t *testing.T) {
|
||||
// This test can be safely deleted when we will not support multiple flag formats
|
||||
root := NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, os.Stdout, os.Stderr)
|
||||
|
||||
if root.Parent() != nil {
|
||||
t.Fatal("We expect the root command to be returned")
|
||||
}
|
||||
if root.GlobalNormalizationFunc() == nil {
|
||||
t.Fatal("We expect that root command has a global normalization function")
|
||||
}
|
||||
|
||||
if reflect.ValueOf(root.GlobalNormalizationFunc()).Pointer() != reflect.ValueOf(root.Flags().GetNormalizeFunc()).Pointer() {
|
||||
t.Fatal("root command seems to have a wrong normalization function")
|
||||
}
|
||||
|
||||
sub := root
|
||||
for sub.HasSubCommands() {
|
||||
sub = sub.Commands()[0]
|
||||
}
|
||||
|
||||
// In case of failure of this test check this PR: spf13/cobra#110
|
||||
if reflect.ValueOf(sub.Flags().GetNormalizeFunc()).Pointer() != reflect.ValueOf(root.Flags().GetNormalizeFunc()).Pointer() {
|
||||
t.Fatal("child and root commands should have the same normalization functions")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user