MCPcopy
hub / github.com/docker/compose / newStream

Function newStream

cmd/compose/compose_progress_test.go:51–69  ·  cmd/compose/compose_progress_test.go::newStream

newStream returns a *streams.Out whose IsTerminal() matches tty. When tty is true it is backed by a pseudo-terminal slave; otherwise by an os.Pipe writer.

(t *testing.T, tty bool)

Source from the content-addressed store, hash-verified

49// newStream returns a *streams.Out whose IsTerminal() matches tty. When tty is
50// true it is backed by a pseudo-terminal slave; otherwise by an os.Pipe writer.
51func newStream(t *testing.T, tty bool) *streams.Out {
52 t.Helper()
53 if tty {
54 ptmx, slave, err := pty.Open()
55 assert.NilError(t, err)
56 t.Cleanup(func() {
57 _ = ptmx.Close()
58 _ = slave.Close()
59 })
60 return streams.NewOut(slave)
61 }
62 r, w, err := os.Pipe()
63 assert.NilError(t, err)
64 t.Cleanup(func() {
65 _ = r.Close()
66 _ = w.Close()
67 })
68 return streams.NewOut(w)
69}
70
71func newMockCli(t *testing.T, out, errStream *streams.Out) *mocks.MockCli {
72 t.Helper()

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected