Accept shared debug bindings
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package commandmeta
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReportingFlagsAreBooleanAndReturnedIndependently(t *testing.T) {
|
||||
flags := ReportingFlags()
|
||||
@@ -33,3 +36,15 @@ func TestReportingFlagsAreBooleanAndReturnedIndependently(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEffectiveFlagsCombinesDebugMetadata(t *testing.T) {
|
||||
flags := []Flag{{Name: "before"}, {Name: "debug", Short: "d", Boolean: true, Default: "true", Required: true, Usage: "application diagnostics", Completion: CompletionHint{Kind: CompletionFiles}}, {Name: "after"}}
|
||||
core := ReportingFlags()
|
||||
got := EffectiveFlags(flags, core)
|
||||
if len(got) != len(flags)+len(core)-1 || got[1].Name != "debug" || got[1].Default != "false" || got[1].Short != "d" || !got[1].Required || got[1].Completion.Kind != CompletionFiles || !strings.Contains(got[1].Usage, "application diagnostics") || !strings.Contains(got[1].Usage, "application input defaults to true") {
|
||||
t.Fatalf("effective debug = %#v", got)
|
||||
}
|
||||
if flags[1].Default != "true" || core[2].Short != "" {
|
||||
t.Fatal("input metadata changed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user