MCPcopy Index your code
hub / github.com/google/go-github / TestCheckResponse_noBody

Function TestCheckResponse_noBody

github/github_test.go:3835–3855  ·  view source on GitHub ↗

Ensure that we properly handle API errors that do not contain a response body.

(t *testing.T)

Source from the content-addressed store, hash-verified

3833
3834// Ensure that we properly handle API errors that do not contain a response body.
3835func TestCheckResponse_noBody(t *testing.T) {
3836 t.Parallel()
3837 res := &http.Response{
3838 Request: &http.Request{},
3839 StatusCode: http.StatusBadRequest,
3840 Body: io.NopCloser(strings.NewReader("")),
3841 }
3842 var err *ErrorResponse
3843 errors.As(CheckResponse(res), &err)
3844
3845 if err == nil {
3846 t.Error("Expected error response.")
3847 }
3848
3849 want := &ErrorResponse{
3850 Response: res,
3851 }
3852 if !errors.Is(err, want) {
3853 t.Errorf("Error = %#v, want %#v", err, want)
3854 }
3855}
3856
3857func TestCheckResponse_unexpectedErrorStructure(t *testing.T) {
3858 t.Parallel()

Callers

nothing calls this directly

Calls 3

CheckResponseFunction · 0.85
ErrorMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…