@@ -291,6 +291,36 @@ func TestUploadFiles_Cancelation(t *testing.T) {
291
291
require .ErrorIs (t , err , gocontext .Canceled )
292
292
}
293
293
294
+ func TestUploadFiles_Errors (t * testing.T ) {
295
+ ctx := gocontext .Background ()
296
+
297
+ server := httptest .NewServer (http .HandlerFunc (func (rw http.ResponseWriter , _ * http.Request ) {
298
+ rw .WriteHeader (http .StatusInternalServerError )
299
+ }))
300
+ defer server .Close ()
301
+
302
+ hu , _ := url .Parse (server .URL )
303
+ tr := apiClient .NewWithClient (hu .Host , "/api/v1" , []string {"http" }, http .DefaultClient )
304
+ client := NewRetryable (tr , strfmt .Default , 1 )
305
+ client .uploadLimit = 1
306
+ ctx = context .WithAuthInfo (ctx , apiClient .BearerToken ("token" ))
307
+
308
+ // Create some files to deploy
309
+ dir , err := ioutil .TempDir ("" , "deploy" )
310
+ require .NoError (t , err )
311
+ defer os .RemoveAll (dir )
312
+ require .NoError (t , ioutil .WriteFile (filepath .Join (dir , "foo.html" ), []byte ("Hello" ), 0644 ))
313
+
314
+ files , err := walk (dir , nil , false , false )
315
+ require .NoError (t , err )
316
+ d := & models.Deploy {}
317
+ for _ , bundle := range files .Files {
318
+ d .Required = append (d .Required , bundle .Sum )
319
+ }
320
+ err = client .uploadFiles (ctx , d , files , nil , fileUpload , time .Minute )
321
+ require .Equal (t , err .Error (), "[PUT /deploys/{deploy_id}/files/{path}][500] uploadDeployFile default &{Code:0 Message:}" )
322
+ }
323
+
294
324
func TestUploadFiles_SkipEqualFiles (t * testing.T ) {
295
325
ctx := gocontext .Background ()
296
326
0 commit comments