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

Function failOnExpectError

internal/prompter/accessible_prompter_test.go:909–930  ·  view source on GitHub ↗

failOnExpectError adds an observer that will fail the test in a standardised way if any expectation on the command output fails, without requiring an explicit assertion. Use WithRelaxedIO to disable this behaviour.

(t *testing.T)

Source from the content-addressed store, hash-verified

907//
908// Use WithRelaxedIO to disable this behaviour.
909func failOnExpectError(t *testing.T) expect.ConsoleOpt {
910 t.Helper()
911 return expect.WithExpectObserver(
912 func(matchers []expect.Matcher, buf string, err error) {
913 t.Helper()
914
915 if err == nil {
916 return
917 }
918
919 if len(matchers) == 0 {
920 t.Fatalf("Error occurred while matching %q: %s\n", buf, err)
921 }
922
923 var criteria []string
924 for _, matcher := range matchers {
925 criteria = append(criteria, fmt.Sprintf("%q", matcher.Criteria()))
926 }
927 t.Fatalf("Failed to find [%s] in %q: %s\n", strings.Join(criteria, ", "), buf, err)
928 },
929 )
930}
931
932// failOnSendError adds an observer that will fail the test in a standardised way
933// if any sending of input fails, without requiring an explicit assertion.

Callers 1

newTestVirtualTerminalFunction · 0.70

Calls 2

JoinMethod · 0.80
HelperMethod · 0.65

Tested by

no test coverage detected