MCPcopy
hub / github.com/spf13/pflag / TestDeprecatedFlagUsageNormalized

Function TestDeprecatedFlagUsageNormalized

flag_test.go:1213–1229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1211}
1212
1213func TestDeprecatedFlagUsageNormalized(t *testing.T) {
1214 f := NewFlagSet("bob", ContinueOnError)
1215 f.Bool("bad-double_flag", true, "always true")
1216 f.SetNormalizeFunc(wordSepNormalizeFunc)
1217 usageMsg := "use --good-flag instead"
1218 f.MarkDeprecated("bad_double-flag", usageMsg)
1219
1220 args := []string{"--bad_double_flag"}
1221 out, err := parseReturnStderr(t, f, args)
1222 if err != nil {
1223 t.Fatal("expected no error; got ", err)
1224 }
1225
1226 if !strings.Contains(out, usageMsg) {
1227 t.Errorf("usageMsg not printed when using a deprecated flag!")
1228 }
1229}
1230
1231// Name normalization function should be called only once on flag addition
1232func TestMultipleNormalizeFlagNameInvocations(t *testing.T) {

Callers

nothing calls this directly

Calls 5

BoolMethod · 0.95
SetNormalizeFuncMethod · 0.95
MarkDeprecatedMethod · 0.95
NewFlagSetFunction · 0.85
parseReturnStderrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…