MCPcopy
hub / github.com/spf13/cobra / TestNormPassedOnLocal

Function TestNormPassedOnLocal

command_test.go:1809–1820  ·  view source on GitHub ↗

Related to https://github.com/spf13/cobra/issues/521.

(t *testing.T)

Source from the content-addressed store, hash-verified

1807
1808// Related to https://github.com/spf13/cobra/issues/521.
1809func TestNormPassedOnLocal(t *testing.T) {
1810 toUpper := func(f *pflag.FlagSet, name string) pflag.NormalizedName {
1811 return pflag.NormalizedName(strings.ToUpper(name))
1812 }
1813
1814 c := &Command{}
1815 c.Flags().Bool("flagname", true, "this is a dummy flag")
1816 c.SetGlobalNormalizationFunc(toUpper)
1817 if c.LocalFlags().Lookup("flagname") != c.LocalFlags().Lookup("FLAGNAME") {
1818 t.Error("Normalization function should be passed on to Local flag set")
1819 }
1820}
1821
1822// Related to https://github.com/spf13/cobra/issues/521.
1823func TestNormPassedOnInherited(t *testing.T) {

Callers

nothing calls this directly

Calls 4

FlagsMethod · 0.95
LocalFlagsMethod · 0.95
ErrorMethod · 0.80

Tested by

no test coverage detected