mirror of
https://github.com/versity/versitygw.git
synced 2026-08-15 19:56:15 +00:00
fix: Fixes #195, fixed DeleteObjects action response structure
This commit is contained in:
@@ -1058,7 +1058,7 @@ func (p *Posix) DeleteObjects(ctx context.Context, input *s3.DeleteObjectsInput)
|
||||
|
||||
return s3response.DeleteObjectsResult{
|
||||
Deleted: delResult,
|
||||
Errors: errs,
|
||||
Error: errs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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"
|
||||
|
||||
@@ -116,7 +116,7 @@ type DeleteObjects struct {
|
||||
|
||||
type DeleteObjectsResult struct {
|
||||
Deleted []types.DeletedObject
|
||||
Errors []types.Error
|
||||
Error []types.Error
|
||||
}
|
||||
type SelectObjectContentPayload struct {
|
||||
Expression *string
|
||||
|
||||
Reference in New Issue
Block a user