MCPcopy Index your code
hub / github.com/google/go-github / TestNewRequest_emptyUserAgent

Function TestNewRequest_emptyUserAgent

github/github_test.go:1626–1637  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1626func 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

Callers

nothing calls this directly

Calls 2

mustNewClientFunction · 0.85
NewRequestMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…