mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
Refactor adding logging flags
This commit is contained in:
parent
a5faf9f920
commit
09cc27e609
2 changed files with 36 additions and 7 deletions
|
|
@ -178,3 +178,34 @@ func TestParseHeaderArgs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlags(t *testing.T) {
|
||||
cmd := &PrometheusAdapter{
|
||||
PrometheusURL: "https://localhost",
|
||||
}
|
||||
cmd.addFlags()
|
||||
|
||||
flags := cmd.FlagSet
|
||||
if flags == nil {
|
||||
t.Fatalf("FlagSet should not be nil")
|
||||
}
|
||||
|
||||
expectedFlags := []struct {
|
||||
flag string
|
||||
defaultValue string
|
||||
}{
|
||||
{flag: "v", defaultValue: "0"}, // logging flag (klog)
|
||||
{flag: "prometheus-url", defaultValue: "https://localhost"}, // default is set in cmd
|
||||
}
|
||||
|
||||
for _, e := range expectedFlags {
|
||||
flag := flags.Lookup(e.flag)
|
||||
if flag == nil {
|
||||
t.Errorf("Flag %q expected to be present, was absent", e.flag)
|
||||
continue
|
||||
}
|
||||
if flag.DefValue != e.defaultValue {
|
||||
t.Errorf("Expected default value %q for flag %q, got %q", e.defaultValue, e.flag, flag.DefValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue