forked from TrueCloudLab/rclone
vendor: update all dependencies
This commit is contained in:
parent
940df88eb2
commit
d64789528d
4309 changed files with 1327278 additions and 1001118 deletions
63
vendor/github.com/spf13/cobra/command_test.go
generated
vendored
63
vendor/github.com/spf13/cobra/command_test.go
generated
vendored
|
@ -1563,3 +1563,66 @@ func TestUpdateName(t *testing.T) {
|
|||
t.Error("c.Name() should be updated on changed c.Use")
|
||||
}
|
||||
}
|
||||
|
||||
type calledAsTestcase struct {
|
||||
args []string
|
||||
call string
|
||||
want string
|
||||
epm bool
|
||||
tc bool
|
||||
}
|
||||
|
||||
func (tc *calledAsTestcase) test(t *testing.T) {
|
||||
defer func(ov bool) { EnablePrefixMatching = ov }(EnablePrefixMatching)
|
||||
EnablePrefixMatching = tc.epm
|
||||
|
||||
var called *Command
|
||||
run := func(c *Command, _ []string) { t.Logf("called: %q", c.Name()); called = c }
|
||||
|
||||
parent := &Command{Use: "parent", Run: run}
|
||||
child1 := &Command{Use: "child1", Run: run, Aliases: []string{"this"}}
|
||||
child2 := &Command{Use: "child2", Run: run, Aliases: []string{"that"}}
|
||||
|
||||
parent.AddCommand(child1)
|
||||
parent.AddCommand(child2)
|
||||
parent.SetArgs(tc.args)
|
||||
|
||||
output := new(bytes.Buffer)
|
||||
parent.SetOutput(output)
|
||||
|
||||
parent.Execute()
|
||||
|
||||
if called == nil {
|
||||
if tc.call != "" {
|
||||
t.Errorf("missing expected call to command: %s", tc.call)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if called.Name() != tc.call {
|
||||
t.Errorf("called command == %q; Wanted %q", called.Name(), tc.call)
|
||||
} else if got := called.CalledAs(); got != tc.want {
|
||||
t.Errorf("%s.CalledAs() == %q; Wanted: %q", tc.call, got, tc.want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalledAs(t *testing.T) {
|
||||
tests := map[string]calledAsTestcase{
|
||||
"find/no-args": {nil, "parent", "parent", false, false},
|
||||
"find/real-name": {[]string{"child1"}, "child1", "child1", false, false},
|
||||
"find/full-alias": {[]string{"that"}, "child2", "that", false, false},
|
||||
"find/part-no-prefix": {[]string{"thi"}, "", "", false, false},
|
||||
"find/part-alias": {[]string{"thi"}, "child1", "this", true, false},
|
||||
"find/conflict": {[]string{"th"}, "", "", true, false},
|
||||
"traverse/no-args": {nil, "parent", "parent", false, true},
|
||||
"traverse/real-name": {[]string{"child1"}, "child1", "child1", false, true},
|
||||
"traverse/full-alias": {[]string{"that"}, "child2", "that", false, true},
|
||||
"traverse/part-no-prefix": {[]string{"thi"}, "", "", false, true},
|
||||
"traverse/part-alias": {[]string{"thi"}, "child1", "this", true, true},
|
||||
"traverse/conflict": {[]string{"th"}, "", "", true, true},
|
||||
}
|
||||
|
||||
for name, tc := range tests {
|
||||
t.Run(name, tc.test)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue