mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
fix(i18n): add a test for plurality of required flags
This commit is contained in:
parent
64f5c4f405
commit
102ab5b544
1 changed files with 15 additions and 0 deletions
|
@ -815,6 +815,21 @@ func TestPersistentFlagsOnChild(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRequiredFlag(t *testing.T) {
|
||||||
|
c := &Command{Use: "c", Run: emptyRun}
|
||||||
|
c.Flags().String("foo1", "", "")
|
||||||
|
assertNoErr(t, c.MarkFlagRequired("foo1"))
|
||||||
|
|
||||||
|
expected := fmt.Sprintf("required flag %q is not set", "foo1")
|
||||||
|
|
||||||
|
_, err := executeCommand(c)
|
||||||
|
got := err.Error()
|
||||||
|
|
||||||
|
if got != expected {
|
||||||
|
t.Errorf("Expected error: %q, got: %q", expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRequiredFlags(t *testing.T) {
|
func TestRequiredFlags(t *testing.T) {
|
||||||
c := &Command{Use: "c", Run: emptyRun}
|
c := &Command{Use: "c", Run: emptyRun}
|
||||||
c.Flags().String("foo1", "", "")
|
c.Flags().String("foo1", "", "")
|
||||||
|
|
Loading…
Reference in a new issue