MCPcopy
hub / github.com/urfave/cli / TestCommand_ParseSliceFlagsWithMissingValue

Function TestCommand_ParseSliceFlagsWithMissingValue

command_test.go:1488–1514  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1486}
1487
1488func TestCommand_ParseSliceFlagsWithMissingValue(t *testing.T) {
1489 var parsedIntSlice []int64
1490 var parsedStringSlice []string
1491
1492 cmd := &Command{
1493 Commands: []*Command{
1494 {
1495 Name: "cmd",
1496 Flags: []Flag{
1497 &Int64SliceFlag{Name: "a", Usage: "set numbers"},
1498 &StringSliceFlag{Name: "str", Usage: "set strings"},
1499 },
1500 Action: func(_ context.Context, cmd *Command) error {
1501 parsedIntSlice = cmd.Int64Slice("a")
1502 parsedStringSlice = cmd.StringSlice("str")
1503 return nil
1504 },
1505 },
1506 },
1507 }
1508
1509 r := require.New(t)
1510
1511 r.NoError(cmd.Run(buildTestContext(t), []string{"", "cmd", "-a", "2", "-str", "A"}))
1512 r.Equal([]int64{2}, parsedIntSlice)
1513 r.Equal([]string{"A"}, parsedStringSlice)
1514}
1515
1516func TestCommand_DefaultStdin(t *testing.T) {
1517 cmd := &Command{}

Callers

nothing calls this directly

Calls 4

Int64SliceMethod · 0.95
StringSliceMethod · 0.95
RunMethod · 0.95
buildTestContextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…