MCPcopy
hub / github.com/istio/istio / TestExcludeFlagCommaHandling

Function TestExcludeFlagCommaHandling

tools/bug-report/pkg/bugreport/flags_test.go:94–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestExcludeFlagCommaHandling(t *testing.T) {
95 // Reset global state.
96 included = nil
97 excluded = nil
98 gConfig = &config2.BugReportConfig{}
99
100 cmd := &cobra.Command{Use: "test"}
101 addFlags(cmd, gConfig)
102 args := []string{"--exclude", "my-app-ns,my-other-ns"}
103 if err := cmd.ParseFlags(args); err != nil {
104 t.Fatal(err)
105 }
106
107 config, err := parseConfig()
108 if err != nil {
109 t.Fatal(err)
110 }
111
112 // The first exclude entry is the default (IgnoredNamespaces).
113 // The second should be our flag value with both namespaces together.
114 if len(config.Exclude) < 2 {
115 t.Fatalf("expected at least 2 exclude specs, got %d", len(config.Exclude))
116 }
117 assert.Equal(t, config.Exclude[1].Namespaces, []string{"my-app-ns", "my-other-ns"})
118}

Callers

nothing calls this directly

Calls 5

EqualFunction · 0.92
addFlagsFunction · 0.70
parseConfigFunction · 0.70
FatalMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…