(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func TestRequestReturnsBodyUnread(t *testing.T) { |
| 124 | reg := &httpmock.Registry{} |
| 125 | defer reg.Verify(t) |
| 126 | client := newTestClient(reg) |
| 127 | |
| 128 | reg.Register(httpmock.MatchAny, httpmock.StatusStringResponse(200, "the raw body")) |
| 129 | |
| 130 | resp, err := client.Request("github.com", http.MethodGet, "repos/OWNER/REPO/contents/f", nil) |
| 131 | require.NoError(t, err) |
| 132 | defer resp.Body.Close() |
| 133 | |
| 134 | body, err := io.ReadAll(resp.Body) |
| 135 | require.NoError(t, err) |
| 136 | assert.Equal(t, "the raw body", string(body)) |
| 137 | } |
| 138 | |
| 139 | // REST treats 204 and 205 specially and decodes every other 2xx as JSON. Request must do neither, |
| 140 | // so that bodiless successes and non-JSON successes both work. |
nothing calls this directly
no test coverage detected