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

Function TestCommand_SetStdin_Subcommand

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

Source from the content-addressed store, hash-verified

1545}
1546
1547func TestCommand_SetStdin_Subcommand(t *testing.T) {
1548 buf := make([]byte, 12)
1549
1550 cmd := &Command{
1551 Name: "test",
1552 Reader: strings.NewReader("Hello World!"),
1553 Commands: []*Command{
1554 {
1555 Name: "command",
1556 Commands: []*Command{
1557 {
1558 Name: "subcommand",
1559 Action: func(_ context.Context, cmd *Command) error {
1560 _, err := cmd.Root().Reader.Read(buf)
1561 return err
1562 },
1563 },
1564 },
1565 },
1566 },
1567 }
1568
1569 err := cmd.Run(buildTestContext(t), []string{"test", "command", "subcommand"})
1570 require.NoError(t, err)
1571 assert.Equal(t, "Hello World!", string(buf), "Command did not read input from desired reader.")
1572}
1573
1574func TestCommand_SetStdout(t *testing.T) {
1575 var w bytes.Buffer

Callers

nothing calls this directly

Calls 3

RootMethod · 0.95
RunMethod · 0.95
buildTestContextFunction · 0.85

Tested by

no test coverage detected