fix: Fixes #195, fixed DeleteObjects action response structure

This commit is contained in:
jonaustin09
2023-08-24 18:37:01 +04:00
parent 56f452f1a2
commit a2439264b2
4 changed files with 33 additions and 35 deletions
+1 -1
View File
@@ -1058,7 +1058,7 @@ func (p *Posix) DeleteObjects(ctx context.Context, input *s3.DeleteObjectsInput)
return s3response.DeleteObjectsResult{
Deleted: delResult,
Errors: errs,
Error: errs,
}, nil
}
+1 -2
View File
@@ -52,8 +52,7 @@ func TestDeleteObject(s *S3Conf) {
func TestDeleteObjects(s *S3Conf) {
DeleteObjects_empty_input(s)
//TODO: Uncomment this after fixing the bug: #195
// DeleteObjects_non_existing_objects(s)
DeleteObjects_non_existing_objects(s)
DeleteObjects_success(s)
}
+30 -31
View File
@@ -713,40 +713,39 @@ func DeleteObjects_empty_input(s *S3Conf) {
})
}
//TODO: Uncomment the test after fixing the bug: #195
// func DeleteObjects_non_existing_objects(s *S3Conf) {
// testName := "DeleteObjects_empty_input"
// actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
// delObjects := []types.ObjectIdentifier{{Key: getPtr("obj1")}, {Key: getPtr("obj2")}}
//
// ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
// out, err := s3client.DeleteObjects(ctx, &s3.DeleteObjectsInput{
// Bucket: &bucket,
// Delete: &types.Delete{
// Objects: delObjects,
// },
// })
// cancel()
// if err != nil {
// return err
// }
func DeleteObjects_non_existing_objects(s *S3Conf) {
testName := "DeleteObjects_empty_input"
actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
delObjects := []types.ObjectIdentifier{{Key: getPtr("obj1")}, {Key: getPtr("obj2")}}
// if len(out.Deleted) != 0 {
// return fmt.Errorf("expected deleted object count 0, instead got %v", len(out.Deleted))
// }
// if len(out.Errors) != 2 {
// return fmt.Errorf("expected 2 errors, instead got %v", len(out.Errors))
// }
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
out, err := s3client.DeleteObjects(ctx, &s3.DeleteObjectsInput{
Bucket: &bucket,
Delete: &types.Delete{
Objects: delObjects,
},
})
cancel()
if err != nil {
return err
}
// for _, delErr := range out.Errors {
// if *delErr.Code != "NoSuchKey" {
// return fmt.Errorf("expected NoSuchKey error, instead got %v", *delErr.Code)
// }
// }
if len(out.Deleted) != 0 {
return fmt.Errorf("expected deleted object count 0, instead got %v", len(out.Deleted))
}
if len(out.Errors) != 2 {
return fmt.Errorf("expected 2 errors, instead got %v", len(out.Errors))
}
// return nil
// })
// }
for _, delErr := range out.Errors {
if *delErr.Code != "NoSuchKey" {
return fmt.Errorf("expected NoSuchKey error, instead got %v", *delErr.Code)
}
}
return nil
})
}
func DeleteObjects_success(s *S3Conf) {
testName := "DeleteObjects_success"
+1 -1
View File
@@ -116,7 +116,7 @@ type DeleteObjects struct {
type DeleteObjectsResult struct {
Deleted []types.DeletedObject
Errors []types.Error
Error []types.Error
}
type SelectObjectContentPayload struct {
Expression *string