If a nil body is passed to github.NewRequest, make sure that nil is also passed to http.NewRequest. In most cases, passing an io.Reader that returns no content is fine, since there is no difference between an HTTP request body that is an empty string versus one that is not set at all. However in cer
(t *testing.T)
| 1643 | // certain cases, intermediate systems may treat these differently resulting in |
| 1644 | // subtle errors. |
| 1645 | func TestNewRequest_emptyBody(t *testing.T) { |
| 1646 | t.Parallel() |
| 1647 | c := mustNewClient(t) |
| 1648 | req, err := c.NewRequest(t.Context(), "GET", ".", nil) |
| 1649 | if err != nil { |
| 1650 | t.Fatalf("NewRequest returned unexpected error: %v", err) |
| 1651 | } |
| 1652 | if req.Body != nil { |
| 1653 | t.Fatal("constructed request contains a non-nil Body") |
| 1654 | } |
| 1655 | } |
| 1656 | |
| 1657 | func TestNewRequest_errorForNoTrailingSlash(t *testing.T) { |
| 1658 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…