forked from TrueCloudLab/rclone
vendor: update all dependencies
This commit is contained in:
parent
3f0789e2db
commit
08021c4636
2474 changed files with 435818 additions and 282709 deletions
105
vendor/github.com/spf13/cobra/command_test.go
generated
vendored
105
vendor/github.com/spf13/cobra/command_test.go
generated
vendored
|
@ -1626,3 +1626,108 @@ func TestCalledAs(t *testing.T) {
|
|||
t.Run(name, tc.test)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFParseErrWhitelistBackwardCompatibility(t *testing.T) {
|
||||
c := &Command{Use: "c", Run: emptyRun}
|
||||
c.Flags().BoolP("boola", "a", false, "a boolean flag")
|
||||
|
||||
output, err := executeCommand(c, "c", "-a", "--unknown", "flag")
|
||||
if err == nil {
|
||||
t.Error("expected unknown flag error")
|
||||
}
|
||||
checkStringContains(t, output, "unknown flag: --unknown")
|
||||
}
|
||||
|
||||
func TestFParseErrWhitelistSameCommand(t *testing.T) {
|
||||
c := &Command{
|
||||
Use: "c",
|
||||
Run: emptyRun,
|
||||
FParseErrWhitelist: FParseErrWhitelist{
|
||||
UnknownFlags: true,
|
||||
},
|
||||
}
|
||||
c.Flags().BoolP("boola", "a", false, "a boolean flag")
|
||||
|
||||
_, err := executeCommand(c, "c", "-a", "--unknown", "flag")
|
||||
if err != nil {
|
||||
t.Error("unexpected error: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFParseErrWhitelistParentCommand(t *testing.T) {
|
||||
root := &Command{
|
||||
Use: "root",
|
||||
Run: emptyRun,
|
||||
FParseErrWhitelist: FParseErrWhitelist{
|
||||
UnknownFlags: true,
|
||||
},
|
||||
}
|
||||
|
||||
c := &Command{
|
||||
Use: "child",
|
||||
Run: emptyRun,
|
||||
}
|
||||
c.Flags().BoolP("boola", "a", false, "a boolean flag")
|
||||
|
||||
root.AddCommand(c)
|
||||
|
||||
output, err := executeCommand(root, "child", "-a", "--unknown", "flag")
|
||||
if err == nil {
|
||||
t.Error("expected unknown flag error")
|
||||
}
|
||||
checkStringContains(t, output, "unknown flag: --unknown")
|
||||
}
|
||||
|
||||
func TestFParseErrWhitelistChildCommand(t *testing.T) {
|
||||
root := &Command{
|
||||
Use: "root",
|
||||
Run: emptyRun,
|
||||
}
|
||||
|
||||
c := &Command{
|
||||
Use: "child",
|
||||
Run: emptyRun,
|
||||
FParseErrWhitelist: FParseErrWhitelist{
|
||||
UnknownFlags: true,
|
||||
},
|
||||
}
|
||||
c.Flags().BoolP("boola", "a", false, "a boolean flag")
|
||||
|
||||
root.AddCommand(c)
|
||||
|
||||
_, err := executeCommand(root, "child", "-a", "--unknown", "flag")
|
||||
if err != nil {
|
||||
t.Error("unexpected error: ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestFParseErrWhitelistSiblingCommand(t *testing.T) {
|
||||
root := &Command{
|
||||
Use: "root",
|
||||
Run: emptyRun,
|
||||
}
|
||||
|
||||
c := &Command{
|
||||
Use: "child",
|
||||
Run: emptyRun,
|
||||
FParseErrWhitelist: FParseErrWhitelist{
|
||||
UnknownFlags: true,
|
||||
},
|
||||
}
|
||||
c.Flags().BoolP("boola", "a", false, "a boolean flag")
|
||||
|
||||
s := &Command{
|
||||
Use: "sibling",
|
||||
Run: emptyRun,
|
||||
}
|
||||
s.Flags().BoolP("boolb", "b", false, "a boolean flag")
|
||||
|
||||
root.AddCommand(c)
|
||||
root.AddCommand(s)
|
||||
|
||||
output, err := executeCommand(root, "sibling", "-b", "--unknown", "flag")
|
||||
if err == nil {
|
||||
t.Error("expected unknown flag error")
|
||||
}
|
||||
checkStringContains(t, output, "unknown flag: --unknown")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue