(t *testing.T)
| 1545 | } |
| 1546 | |
| 1547 | func 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 | |
| 1574 | func TestCommand_SetStdout(t *testing.T) { |
| 1575 | var w bytes.Buffer |
nothing calls this directly
no test coverage detected