Skip to content

Commit

Permalink
Add ext flag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Oct 20, 2024
1 parent 1325e29 commit 7d27b3d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3002,3 +3002,31 @@ func TestZeroValueMutexFlag(t *testing.T) {
var fl MutuallyExclusiveFlags
assert.NoError(t, fl.check(&Command{}))
}

func TestExtFlag(t *testing.T) {
fs := flag.NewFlagSet("foo", flag.ContinueOnError)

var iv intValue
var ipv int64

f := &flag.Flag{
Name: "bar",
Usage: "bar usage",
Value: iv.Create(11, &ipv, IntegerConfig{}),
DefValue: "10",
}

extF := &extFlag{
f: f,
}

assert.NoError(t, extF.Apply(fs))
assert.Equal(t, []string{"bar"}, extF.Names())
assert.True(t, extF.IsVisible())
assert.False(t, extF.IsSet())
assert.False(t, extF.TakesValue())
assert.Equal(t, "bar usage", extF.GetUsage())
assert.Equal(t, "11", extF.GetValue())
assert.Equal(t, "10", extF.GetDefaultText())
assert.Nil(t, extF.GetEnvVars())
}

0 comments on commit 7d27b3d

Please sign in to comment.