mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
2cd9d9073e
git-subtree-dir: third_party/src/github.com/codegangsta/cli git-subtree-split: f7ebb761e83e21225d1d8954fde853bf8edd46c4
50 lines
1017 B
Go
50 lines
1017 B
Go
package cli_test
|
|
|
|
import (
|
|
"flag"
|
|
"testing"
|
|
|
|
"github.com/codegangsta/cli"
|
|
)
|
|
|
|
func TestCommandDoNotIgnoreFlags(t *testing.T) {
|
|
app := cli.NewApp()
|
|
set := flag.NewFlagSet("test", 0)
|
|
test := []string{"blah", "blah", "-break"}
|
|
set.Parse(test)
|
|
|
|
c := cli.NewContext(app, set, set)
|
|
|
|
command := cli.Command{
|
|
Name: "test-cmd",
|
|
ShortName: "tc",
|
|
Usage: "this is for testing",
|
|
Description: "testing",
|
|
Action: func(_ *cli.Context) {},
|
|
}
|
|
err := command.Run(c)
|
|
|
|
expect(t, err.Error(), "flag provided but not defined: -break")
|
|
}
|
|
|
|
func TestCommandIgnoreFlags(t *testing.T) {
|
|
app := cli.NewApp()
|
|
set := flag.NewFlagSet("test", 0)
|
|
test := []string{"blah", "blah"}
|
|
set.Parse(test)
|
|
|
|
c := cli.NewContext(app, set, set)
|
|
|
|
command := cli.Command{
|
|
Name: "test-cmd",
|
|
ShortName: "tc",
|
|
Usage: "this is for testing",
|
|
Description: "testing",
|
|
Action: func(_ *cli.Context) {},
|
|
SkipFlagParsing: true,
|
|
}
|
|
err := command.Run(c)
|
|
|
|
expect(t, err, nil)
|
|
}
|