@@ -233,3 +233,46 @@ func TestGetBulkPartialObjectRandomAccess(t *testing.T) {
233233 testutils .VerifyPartialFile (t , LargeBookPath + LargeBookTitle , 201 , 200 , file )
234234 testutils .VerifyPartialFile (t , LargeBookPath + LargeBookTitle , 101 , 500 , file )
235235}
236+
237+ func TestPutObjectDoesNotExist (t * testing.T ) {
238+ defer testutils .DeleteBucketContents (client , testBucket )
239+ helper := helpers .NewHelpers (client )
240+
241+ strategy := newTestTransferStrategy ()
242+
243+ channelBuilder := channels .NewReadChannelBuilder ("does-not-exist" )
244+ nonExistentPutObj := helperModels.PutObject {
245+ PutObject : ds3Models.Ds3PutObject {Name :"does-not-exist" ,Size :10 },
246+ ChannelBuilder : channelBuilder ,
247+ }
248+
249+ writeObjects := []helperModels.PutObject { nonExistentPutObj }
250+
251+ jobId , err := helper .PutObjects (testBucket , writeObjects , strategy )
252+
253+ // Verify that the expected error occurred instead of a panic
254+ if err == nil {
255+ t .Fatal ("expected to get an error due to file not existing" )
256+ }
257+ aggErr , ok := err .(* ds3Models.AggregateError )
258+ if ! ok {
259+ t .Fatal ("expected error to be of type AggregateError" )
260+ }
261+ if len (aggErr .Errors ) != 1 {
262+ t .Fatalf ("expected 1 aggregate error, but got %d" , len (aggErr .Errors ))
263+ }
264+ expected := "open does-not-exist: no such file or directory"
265+ ds3Testing .AssertString (t , "expected error" , expected , aggErr .Errors [0 ].Error ())
266+
267+
268+ if jobId == "" {
269+ t .Error ("expected to get a BP job ID, but instead got nothing" )
270+ }
271+
272+ // verify nothing is on the BP
273+ getBucket , getBucketErr := client .GetBucket (ds3Models .NewGetBucketRequest (testBucket ))
274+ ds3Testing .AssertNilError (t , getBucketErr )
275+ if len (getBucket .ListBucketResult .Objects ) != 0 {
276+ t .Fatalf ("Expected '%d' objects in bucket '%s', but found '%d'." , 0 , testBucket , len (getBucket .ListBucketResult .Objects ))
277+ }
278+ }
0 commit comments