@@ -101,4 +101,32 @@ func TestOpenAPIClientWithWeirdResponse(t *testing.T) {
101101 _ , operationError := client .Operations .UploadDeployFile (params , authInfo )
102102 require .Error (t , operationError )
103103 require .Equal (t , "[PUT /deploys/{deploy_id}/files/{path}][408] uploadDeployFile default &{Code:408 Message:a message}" , operationError .Error ())
104+
105+ }
106+
107+ func TestConcurrentFileUpload (t * testing.T ) {
108+ server := httptest .NewServer (http .HandlerFunc (func (rw http.ResponseWriter , req * http.Request ) {
109+ rw .Header ().Set ("Content-Type" , "application/json; charset=utf-8" )
110+ rw .WriteHeader (408 )
111+ rw .Write ([]byte (`{ "foo": "bar", "message": "a message", "code": 408 }` ))
112+ }))
113+ defer server .Close ()
114+
115+ httpClient := http .DefaultClient
116+ authInfo := runtime .ClientAuthInfoWriterFunc (func (r runtime.ClientRequest , _ strfmt.Registry ) error {
117+ r .SetHeaderParam ("User-Agent" , "buildbot" )
118+ r .SetHeaderParam ("Authorization" , "Bearer 1234" )
119+ return nil
120+ })
121+
122+ hu , _ := url .Parse (server .URL )
123+ tr := apiClient .NewWithClient (hu .Host , "/api/v1" , []string {"http" }, httpClient )
124+ client := NewRetryable (tr , strfmt .Default , 1 )
125+ for i := 0 ; i < 30 ; i ++ {
126+ go func () {
127+ body := ioutil .NopCloser (bytes .NewReader ([]byte ("hello world" )))
128+ params := operations .NewUploadDeployFileParams ().WithDeployID ("1234" ).WithPath ("foo/bar/biz" ).WithFileBody (body )
129+ _ , _ = client .Operations .UploadDeployFile (params , authInfo )
130+ }()
131+ }
104132}
0 commit comments