ensure that no User-Agent header is set if the client's UserAgent is empty. This caused a problem with Google's internal http client.
(t *testing.T)
| 1624 | // ensure that no User-Agent header is set if the client's UserAgent is empty. |
| 1625 | // This caused a problem with Google's internal http client. |
| 1626 | func TestNewRequest_emptyUserAgent(t *testing.T) { |
| 1627 | t.Parallel() |
| 1628 | c := mustNewClient(t) |
| 1629 | c.userAgent = "" |
| 1630 | req, err := c.NewRequest(t.Context(), "GET", ".", nil) |
| 1631 | if err != nil { |
| 1632 | t.Fatalf("NewRequest returned unexpected error: %v", err) |
| 1633 | } |
| 1634 | if _, ok := req.Header["User-Agent"]; ok { |
| 1635 | t.Fatal("constructed request contains unexpected User-Agent header") |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | // If a nil body is passed to github.NewRequest, make sure that nil is also |
| 1640 | // passed to http.NewRequest. In most cases, passing an io.Reader that returns |
nothing calls this directly
no test coverage detected
searching dependent graphs…