(t *testing.T)
| 265 | } |
| 266 | |
| 267 | func TestIsStatusCode(t *testing.T) { |
| 268 | tests := []struct { |
| 269 | Error interface{} |
| 270 | Code int |
| 271 | Want bool |
| 272 | }{ |
| 273 | // #0 |
| 274 | { |
| 275 | Error: nil, |
| 276 | Code: 200, |
| 277 | Want: false, |
| 278 | }, |
| 279 | // #1 |
| 280 | { |
| 281 | Error: "", |
| 282 | Code: 200, |
| 283 | Want: false, |
| 284 | }, |
| 285 | // #2 |
| 286 | { |
| 287 | Error: http.StatusConflict, |
| 288 | Code: 409, |
| 289 | Want: true, |
| 290 | }, |
| 291 | // #3 |
| 292 | { |
| 293 | Error: http.StatusConflict, |
| 294 | Code: http.StatusInternalServerError, |
| 295 | Want: false, |
| 296 | }, |
| 297 | // #4 |
| 298 | { |
| 299 | Error: &Error{Status: http.StatusConflict}, |
| 300 | Code: 409, |
| 301 | Want: true, |
| 302 | }, |
| 303 | // #5 |
| 304 | { |
| 305 | Error: Error{Status: http.StatusConflict}, |
| 306 | Code: 409, |
| 307 | Want: true, |
| 308 | }, |
| 309 | // #6 |
| 310 | { |
| 311 | Error: &http.Response{StatusCode: http.StatusConflict}, |
| 312 | Code: 409, |
| 313 | Want: true, |
| 314 | }, |
| 315 | } |
| 316 | |
| 317 | for i, tt := range tests { |
| 318 | if have, want := IsStatusCode(tt.Error, tt.Code), tt.Want; have != want { |
| 319 | t.Errorf("#%d: have %v, want %v", i, have, want) |
| 320 | } |
| 321 | } |
| 322 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…