MCPcopy Create free account
hub / github.com/Shopify/goose / TestCommandStdinBeforeStart

Function TestCommandStdinBeforeStart

shell/shell_test.go:255–273  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

253}
254
255func TestCommandStdinBeforeStart(t *testing.T) {
256 ctx := context.Background()
257 cmd := New(ctx, "bash", "-c", "cat; echo -n foo")
258
259 c := cmd.Cmd()
260 stdin, err := c.StdinPipe()
261 assert.NoError(t, err)
262
263 _, err = stdin.Write([]byte("bar"))
264 assert.NoError(t, err)
265
266 err = stdin.Close()
267 assert.NoError(t, err)
268
269 stdout, _, err := cmd.RunAndGetOutput()
270 assert.NoError(t, err)
271
272 assert.Equal(t, "barfoo", string(stdout))
273}
274
275func TestCommandStdinAfterStart(t *testing.T) {
276 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

CloseMethod · 0.80
NewFunction · 0.70
CmdMethod · 0.65
RunAndGetOutputMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected