Skip to content

Commit 25404f2

Browse files
committed
create ClientOptions using NewHTTPClient
1 parent b900fe7 commit 25404f2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

mongo/options/clientoptions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ type ClientOptions struct {
302302
// Client creates a new ClientOptions instance.
303303
func Client() *ClientOptions {
304304
opts := &ClientOptions{}
305-
opts = opts.SetHTTPClient(httputil.DefaultHTTPClient)
305+
opts = opts.SetHTTPClient(httputil.NewHTTPClient())
306306

307307
return opts
308308
}

mongo/options/clientoptions_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,16 @@ func TestClientOptions(t *testing.T) {
525525
})
526526
}
527527

528+
type nonDefaultTransport struct{}
529+
530+
func (*nonDefaultTransport) RoundTrip(*http.Request) (*http.Response, error) { return nil, nil }
531+
532+
func TestClientHTTPTransport(t *testing.T) {
533+
http.DefaultTransport = &nonDefaultTransport{}
534+
got := Client().HTTPClient.Transport
535+
assert.Equal(t, &nonDefaultTransport{}, got)
536+
}
537+
528538
func createCertPool(t *testing.T, paths ...string) *x509.CertPool {
529539
t.Helper()
530540

0 commit comments

Comments
 (0)