(t *testing.T)
| 3262 | } |
| 3263 | |
| 3264 | func TestCheckResponse(t *testing.T) { |
| 3265 | t.Parallel() |
| 3266 | res := &http.Response{ |
| 3267 | Request: &http.Request{}, |
| 3268 | StatusCode: http.StatusBadRequest, |
| 3269 | Body: io.NopCloser(strings.NewReader(`{"message":"m", |
| 3270 | "errors": [{"resource": "r", "field": "f", "code": "c"}], |
| 3271 | "block": {"reason": "dmca", "created_at": "2016-03-17T15:39:46Z"}}`)), |
| 3272 | } |
| 3273 | var err *ErrorResponse |
| 3274 | errors.As(CheckResponse(res), &err) |
| 3275 | |
| 3276 | if err == nil { |
| 3277 | t.Error("Expected error response.") |
| 3278 | } |
| 3279 | |
| 3280 | want := &ErrorResponse{ |
| 3281 | Response: res, |
| 3282 | Message: "m", |
| 3283 | Errors: []Error{{Resource: "r", Field: "f", Code: "c"}}, |
| 3284 | Block: &ErrorBlock{ |
| 3285 | Reason: "dmca", |
| 3286 | CreatedAt: &Timestamp{time.Date(2016, time.March, 17, 15, 39, 46, 0, time.UTC)}, |
| 3287 | }, |
| 3288 | } |
| 3289 | if !errors.Is(err, want) { |
| 3290 | t.Errorf("Error = %#v, want %#v", err, want) |
| 3291 | } |
| 3292 | } |
| 3293 | |
| 3294 | func TestCheckResponse_RateLimit(t *testing.T) { |
| 3295 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…