(t *testing.T)
| 296 | } |
| 297 | |
| 298 | func TestRequestBody(t *testing.T) { |
| 299 | // test unknown type |
| 300 | r := (&Request{}).Body([]string{"test"}) |
| 301 | if r.err == nil || r.body != nil { |
| 302 | t.Errorf("should have set err and left body nil: %#v", r) |
| 303 | } |
| 304 | |
| 305 | // test error set when failing to read file |
| 306 | f, err := ioutil.TempFile("", "test") |
| 307 | if err != nil { |
| 308 | t.Fatalf("unable to create temp file") |
| 309 | } |
| 310 | defer f.Close() |
| 311 | os.Remove(f.Name()) |
| 312 | r = (&Request{}).Body(f.Name()) |
| 313 | if r.err == nil || r.body != nil { |
| 314 | t.Errorf("should have set err and left body nil: %#v", r) |
| 315 | } |
| 316 | |
| 317 | // test unencodable api object |
| 318 | r = (&Request{content: defaultContentConfig()}).Body(&NotAnAPIObject{}) |
| 319 | if r.err == nil || r.body != nil { |
| 320 | t.Errorf("should have set err and left body nil: %#v", r) |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | func TestResultIntoWithErrReturnsErr(t *testing.T) { |
| 325 | res := Result{err: errors.New("test")} |
nothing calls this directly
no test coverage detected