From 102ab5b544df4c6f520248e4a7c471bee0c39340 Mon Sep 17 00:00:00 2001 From: Goutte Date: Tue, 4 Apr 2023 10:40:59 +0200 Subject: [PATCH] fix(i18n): add a test for plurality of required flags --- command_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/command_test.go b/command_test.go index 98c7ec23..a09c972d 100644 --- a/command_test.go +++ b/command_test.go @@ -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) { c := &Command{Use: "c", Run: emptyRun} c.Flags().String("foo1", "", "")