Related to https://github.com/spf13/cobra/issues/521.
(t *testing.T)
| 1849 | |
| 1850 | // Related to https://github.com/spf13/cobra/issues/521. |
| 1851 | func TestConsistentNormalizedName(t *testing.T) { |
| 1852 | toUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName { |
| 1853 | return pflag.NormalizedName(strings.ToUpper(name)) |
| 1854 | } |
| 1855 | n := func(f *pflag.FlagSet, name string) pflag.NormalizedName { |
| 1856 | return pflag.NormalizedName(name) |
| 1857 | } |
| 1858 | |
| 1859 | c := &Command{} |
| 1860 | c.Flags().Bool("flagname", true, "") |
| 1861 | c.SetGlobalNormalizationFunc(toUpper) |
| 1862 | c.SetGlobalNormalizationFunc(n) |
| 1863 | |
| 1864 | if c.LocalFlags().Lookup("flagname") == c.LocalFlags().Lookup("FLAGNAME") { |
| 1865 | t.Error("Normalizing flag names should not result in duplicate flags") |
| 1866 | } |
| 1867 | } |
| 1868 | |
| 1869 | func TestFlagOnPflagCommandLine(t *testing.T) { |
| 1870 | flagName := "flagOnCommandLine" |
nothing calls this directly
no test coverage detected