@@ -79,7 +79,7 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
7979 gitImpl : gogit .Implementation ,
8080 url : "http://example.com/bar/test-reponame" ,
8181 branch : "main" ,
82- setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxyGotRequest * bool ) (* git.AuthOptions , cleanupFunc ) {
82+ setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxiedRequests * int32 ) (* git.AuthOptions , cleanupFunc ) {
8383 // Create the git server.
8484 gitServer , err := gittestserver .NewTempGitServer ()
8585 g .Expect (err ).ToNot (HaveOccurred ())
@@ -102,7 +102,7 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
102102 var proxyHandler goproxy.FuncReqHandler = func (req * http.Request , ctx * goproxy.ProxyCtx ) (* http.Request , * http.Response ) {
103103 userAgent := req .Header .Get ("User-Agent" )
104104 if strings .Contains (req .Host , "example.com" ) && strings .Contains (userAgent , "git" ) {
105- * proxyGotRequest = true
105+ atomic . AddInt32 ( proxiedRequests , 1 )
106106 req .Host = u .Host
107107 req .URL .Host = req .Host
108108 return req , nil
@@ -130,13 +130,13 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
130130 gitImpl : gogit .Implementation ,
131131 url : "https://github.com/git-fixtures/basic" ,
132132 branch : "master" ,
133- setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxyGotRequest * bool ) (* git.AuthOptions , cleanupFunc ) {
133+ setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxiedRequests * int32 ) (* git.AuthOptions , cleanupFunc ) {
134134 var proxyHandler goproxy.FuncHttpsHandler = func (host string , ctx * goproxy.ProxyCtx ) (* goproxy.ConnectAction , string ) {
135135 // We don't check for user agent as this handler is only going to process CONNECT requests, and because Go's net/http
136136 // is the one making such a request on behalf of go-git, adding a check for the go net/http user agent (Go-http-client)
137137 // would only allow false positives from any request originating from Go's net/http.
138138 if strings .Contains (host , "github.com" ) {
139- * proxyGotRequest = true
139+ atomic . AddInt32 ( proxiedRequests , 1 )
140140 return goproxy .OkConnect , host
141141 }
142142 // Reject if it isnt our request.
@@ -157,10 +157,10 @@ func TestCheckoutStrategyForImplementation_Proxied(t *testing.T) {
157157 gitImpl : gogit .Implementation ,
158158 url : "https://192.0.2.1/bar/test-reponame" ,
159159 branch : "main" ,
160- setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxyGotRequest * bool ) (* git.AuthOptions , cleanupFunc ) {
160+ setupGitProxy : func (g * WithT , proxy * goproxy.ProxyHttpServer , proxiedRequests * int32 ) (* git.AuthOptions , cleanupFunc ) {
161161 var proxyHandler goproxy.FuncHttpsHandler = func (host string , ctx * goproxy.ProxyCtx ) (* goproxy.ConnectAction , string ) {
162162 // We shouldn't hit the proxy so we just want to check for any interaction, then reject.
163- * proxyGotRequest = true
163+ atomic . AddInt32 ( proxiedRequests , 1 )
164164 return goproxy .RejectConnect , host
165165 }
166166 proxy .OnRequest ().HandleConnect (proxyHandler )
0 commit comments