Install shared reporting flags
This commit is contained in:
28
internal/commandmeta/metadata_test.go
Normal file
28
internal/commandmeta/metadata_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package commandmeta
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestReportingFlagsAreBooleanAndReturnedIndependently(t *testing.T) {
|
||||
flags := ReportingFlags()
|
||||
want := []string{"quiet", "verbose", "debug", "progress"}
|
||||
if len(flags) != len(want) {
|
||||
t.Fatalf("reporting flags = %#v", flags)
|
||||
}
|
||||
for index, name := range want {
|
||||
if flags[index].Name != name || !flags[index].Boolean || flags[index].Short != "" || flags[index].Default != "false" {
|
||||
t.Errorf("reporting flag %d = %#v", index, flags[index])
|
||||
}
|
||||
if !IsReportingFlag(name) {
|
||||
t.Errorf("%q is not recognized as a reporting flag", name)
|
||||
}
|
||||
}
|
||||
flags[0].Name = "changed"
|
||||
if ReportingFlags()[0].Name != "quiet" {
|
||||
t.Fatal("caller mutation changed shared reporting metadata")
|
||||
}
|
||||
for _, name := range []string{"help", "quietly", ""} {
|
||||
if IsReportingFlag(name) {
|
||||
t.Errorf("%q was incorrectly recognized as a reporting flag", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user