25 lines
698 B
Go
25 lines
698 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestDebugFlagIsExplicitAndAgentOnly(t *testing.T) {
|
|
for _, flag := range []string{"--debug", "-D"} {
|
|
command := newAgentCommand()
|
|
if err := command.ParseFlags([]string{flag}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
enabled, err := command.Flags().GetBool("debug")
|
|
if err != nil || !enabled {
|
|
t.Fatalf("%s: %v %v", flag, enabled, err)
|
|
}
|
|
if err := newDispatcherCommand().ParseFlags([]string{flag}); err == nil {
|
|
t.Fatal("Dispatcher must not silently accept an Agent capture flag")
|
|
}
|
|
}
|
|
command := newAgentCommand()
|
|
enabled, err := command.Flags().GetBool("debug")
|
|
if err != nil || enabled {
|
|
t.Fatal("capture must be disabled by default")
|
|
}
|
|
}
|