MCPcopy
hub / github.com/cli/cli / newTestVirtualTerminal

Function newTestVirtualTerminal

pkg/iostreams/iostreams_progress_indicator_test.go:152–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func newTestVirtualTerminal(t *testing.T) *expect.Console {
153 t.Helper()
154
155 // Create a PTY and hook up a virtual terminal emulator
156 ptm, pts, err := pty.Open()
157 require.NoError(t, err)
158
159 term := vt10x.New(vt10x.WithWriter(pts))
160
161 // Create a console via Expect that allows scripting against the terminal
162 consoleOpts := []expect.ConsoleOpt{
163 expect.WithStdin(ptm),
164 expect.WithStdout(term),
165 expect.WithCloser(ptm, pts),
166 failOnExpectError(t),
167 failOnSendError(t),
168 expect.WithDefaultTimeout(time.Second),
169 }
170
171 console, err := expect.NewConsole(consoleOpts...)
172 require.NoError(t, err)
173 t.Cleanup(func() { testCloser(t, console) })
174
175 return console
176}
177
178func newTestIOStreams(t *testing.T, console *expect.Console, spinnerDisabled bool) *IOStreams {
179 t.Helper()

Callers 1

Calls 5

OpenMethod · 0.80
failOnExpectErrorFunction · 0.70
failOnSendErrorFunction · 0.70
testCloserFunction · 0.70
HelperMethod · 0.65

Tested by

no test coverage detected