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

Function TestUnHiddenDeprecatedFlagInDocs

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

Source from the content-addressed store, hash-verified

1118}
1119
1120func TestUnHiddenDeprecatedFlagInDocs(t *testing.T) {
1121 f := getDeprecatedFlagSet()
1122 flg := f.Lookup("badflag")
1123 if flg == nil {
1124 t.Fatalf("Unable to lookup 'bob' in TestUnHiddenDeprecatedFlagInDocs")
1125 }
1126 flg.Hidden = false
1127
1128 out := new(bytes.Buffer)
1129 f.SetOutput(out)
1130 f.PrintDefaults()
1131
1132 defaults := out.String()
1133 if !strings.Contains(defaults, "badflag") {
1134 t.Errorf("Did not find deprecated flag in usage!")
1135 }
1136 if !strings.Contains(defaults, "use --good-flag instead") {
1137 t.Errorf("Did not find 'use --good-flag instead' in defaults")
1138 }
1139}
1140
1141func TestDeprecatedFlagShorthandInDocs(t *testing.T) {
1142 f := NewFlagSet("bob", ContinueOnError)

Callers

nothing calls this directly

Calls 5

getDeprecatedFlagSetFunction · 0.85
LookupMethod · 0.80
SetOutputMethod · 0.80
PrintDefaultsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected