MCPcopy Index your code
hub / github.com/cli/cli / failOnSendError

Function failOnSendError

pkg/iostreams/iostreams_progress_indicator_test.go:232–246  ·  view source on GitHub ↗

failOnSendError adds an observer that will fail the test in a standardised way if any sending of input fails, without requiring an explicit assertion. Use WithRelaxedIO to disable this behaviour.

(t *testing.T)

Source from the content-addressed store, hash-verified

230//
231// Use WithRelaxedIO to disable this behaviour.
232func failOnSendError(t *testing.T) expect.ConsoleOpt {
233 t.Helper()
234 return expect.WithSendObserver(
235 func(msg string, n int, err error) {
236 t.Helper()
237
238 if err != nil {
239 t.Fatalf("Failed to send %q: %s\n", msg, err)
240 }
241 if len(msg) != n {
242 t.Fatalf("Only sent %d of %d bytes for %q\n", n, len(msg), msg)
243 }
244 },
245 )
246}
247
248// testCloser is a helper to fail the test if a Closer fails to close.
249func testCloser(t *testing.T, closer io.Closer) {

Callers 1

newTestVirtualTerminalFunction · 0.70

Calls 1

HelperMethod · 0.65

Tested by

no test coverage detected