MCPcopy
hub / github.com/cli/cli / failOnSendError

Function failOnSendError

internal/prompter/accessible_prompter_test.go:936–950  ·  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

934//
935// Use WithRelaxedIO to disable this behaviour.
936func failOnSendError(t *testing.T) expect.ConsoleOpt {
937 t.Helper()
938 return expect.WithSendObserver(
939 func(msg string, n int, err error) {
940 t.Helper()
941
942 if err != nil {
943 t.Fatalf("Failed to send %q: %s\n", msg, err)
944 }
945 if len(msg) != n {
946 t.Fatalf("Only sent %d of %d bytes for %q\n", n, len(msg), msg)
947 }
948 },
949 )
950}
951
952// testCloser is a helper to fail the test if a Closer fails to close.
953func testCloser(t *testing.T, closer io.Closer) {

Callers 1

newTestVirtualTerminalFunction · 0.70

Calls 1

HelperMethod · 0.65

Tested by

no test coverage detected