Related to https://github.com/spf13/cobra/issues/521.
(t *testing.T)
| 1787 | |
| 1788 | // Related to https://github.com/spf13/cobra/issues/521. |
| 1789 | func TestGlobalNormFuncPropagation(t *testing.T) { |
| 1790 | normFunc := func(f *pflag.FlagSet, name string) pflag.NormalizedName { |
| 1791 | return pflag.NormalizedName(name) |
| 1792 | } |
| 1793 | |
| 1794 | rootCmd := &Command{Use: "root", Run: emptyRun} |
| 1795 | childCmd := &Command{Use: "child", Run: emptyRun} |
| 1796 | rootCmd.AddCommand(childCmd) |
| 1797 | |
| 1798 | rootCmd.SetGlobalNormalizationFunc(normFunc) |
| 1799 | if reflect.ValueOf(normFunc).Pointer() != reflect.ValueOf(rootCmd.GlobalNormalizationFunc()).Pointer() { |
| 1800 | t.Error("rootCmd seems to have a wrong normalization function") |
| 1801 | } |
| 1802 | |
| 1803 | if reflect.ValueOf(normFunc).Pointer() != reflect.ValueOf(childCmd.GlobalNormalizationFunc()).Pointer() { |
| 1804 | t.Error("childCmd should have had the normalization function of rootCmd") |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | // Related to https://github.com/spf13/cobra/issues/521. |
| 1809 | func TestNormPassedOnLocal(t *testing.T) { |
nothing calls this directly
no test coverage detected