File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (C) MongoDB, Inc. 2022-present. 
2+ // 
3+ // Licensed under the Apache License, Version 2.0 (the "License"); you may 
4+ // not use this file except in compliance with the License. You may obtain 
5+ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
6+ 
7+ package  httputil
8+ 
9+ import  (
10+ 	"net/http" 
11+ 	"testing" 
12+ 
13+ 	"go.mongodb.org/mongo-driver/v2/internal/assert" 
14+ )
15+ 
16+ type  nonDefaultTransport  struct {}
17+ 
18+ func  (* nonDefaultTransport ) RoundTrip (* http.Request ) (* http.Response , error ) { return  nil , nil  }
19+ 
20+ func  TestDefaultHTTPClientTransport (t  * testing.T ) {
21+ 	t .Run ("default" , func (t  * testing.T ) {
22+ 		client  :=  NewHTTPClient ()
23+ 
24+ 		val  :=  assert .ObjectsAreEqual (http .DefaultClient , client )
25+ 
26+ 		assert .True (t , val )
27+ 		assert .Equal (t , DefaultHTTPClient , client )
28+ 	})
29+ 
30+ 	t .Run ("non-default global transport" , func (t  * testing.T ) {
31+ 		http .DefaultTransport  =  & nonDefaultTransport {}
32+ 
33+ 		client  :=  NewHTTPClient ()
34+ 
35+ 		val  :=  assert .ObjectsAreEqual (& nonDefaultTransport {}, client .Transport )
36+ 
37+ 		assert .True (t , val )
38+ 		assert .Equal (t , DefaultHTTPClient , client )
39+ 		assert .NotEqual (t , http .DefaultClient , client ) // Sanity Check 
40+ 	})
41+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments