Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions flag_mutex_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -58,7 +57,12 @@ func TestFlagMutuallyExclusiveFlags(t *testing.T) {
{
name: "set both flags",
args: []string{"--i", "11", "--ai", "12"},
errStr: "option i cannot be set along with option ai",
errStr: "option i cannot be set along with option t",
},
{
name: "set both flags second member",
args: []string{"--i", "11", "--q"},
errStr: "option i cannot be set along with option q",
},
{
name: "required none set",
Expand All @@ -73,7 +77,7 @@ func TestFlagMutuallyExclusiveFlags(t *testing.T) {
{
name: "required both set",
args: []string{"--i", "11", "--ai", "12"},
errStr: "option i cannot be set along with option ai",
errStr: "option i cannot be set along with option t",
required: true,
},
{
Expand All @@ -82,6 +86,12 @@ func TestFlagMutuallyExclusiveFlags(t *testing.T) {
errStr: "option i cannot be set along with option q",
required: true,
},
{
name: "required both set second member both groups",
args: []string{"--s", "value", "--q"},
errStr: "option s cannot be set along with option q",
required: true,
},
{
name: "set env var",
required: true,
Expand Down Expand Up @@ -113,9 +123,7 @@ func TestFlagMutuallyExclusiveFlags(t *testing.T) {

switch err.(type) {
case (*mutuallyExclusiveGroup), (*mutuallyExclusiveGroupRequiredFlag):
if !strings.Contains(err.Error(), test.errStr) {
t.Logf("Invalid error string %v", err)
}
assert.Contains(t, err.Error(), test.errStr)
default:
t.Errorf("got invalid error type %T", err)
}
Expand Down