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

Function TestCommandRunWaitPipeFails

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

Source from the content-addressed store, hash-verified

156}
157
158func TestCommandRunWaitPipeFails(t *testing.T) {
159 ctx := context.Background()
160 cmd := New(ctx, "bash", "-c", "sleep 0.05; echo -n foo")
161 c := cmd.Cmd()
162
163 pipe, err := c.StdoutPipe()
164 assert.NoError(t, err)
165
166 err = cmd.Run()
167 assert.NoError(t, err)
168
169 // The command completed, and we waited it, so we have a processstate.
170 assert.NotNil(t, c.ProcessState)
171 assert.True(t, c.ProcessState.Exited())
172
173 // Calling ReadAll will wait for the pipe to close, so all the output is there.
174 _, err = io.ReadAll(pipe)
175 assert.Error(t, err, "read |0: file already closed")
176}
177
178func TestCommandWithWorkingDir(t *testing.T) {
179 tempDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
CmdMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected