mirror of https://github.com/minio/minio.git
object: DeleteBucket should return proper error for BucketNotEmpty. (#1489)
Fixes #1488
This commit is contained in:
parent
f145e1042f
commit
82fbe908a3
|
@ -96,7 +96,7 @@ func deleteBucket(storage StorageAPI, bucket string) error {
|
|||
return BucketNameInvalid{Bucket: bucket}
|
||||
}
|
||||
if err := storage.DeleteVol(bucket); err != nil {
|
||||
return toObjectErr(err)
|
||||
return toObjectErr(err, bucket)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ func toObjectErr(err error, params ...string) error {
|
|||
if len(params) >= 1 {
|
||||
return BucketNotFound{Bucket: params[0]}
|
||||
}
|
||||
case errVolumeNotEmpty:
|
||||
if len(params) >= 1 {
|
||||
return BucketNotEmpty{Bucket: params[0]}
|
||||
}
|
||||
case errVolumeExists:
|
||||
if len(params) >= 1 {
|
||||
return BucketExists{Bucket: params[0]}
|
||||
|
|
|
@ -379,6 +379,32 @@ func (s *MyAPISuite) TestDeleteBucket(c *C) {
|
|||
c.Assert(response.StatusCode, Equals, http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (s *MyAPISuite) TestDeleteBucketNotEmpty(c *C) {
|
||||
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/deletebucket-notempty", 0, nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
client := http.Client{}
|
||||
response, err := client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||
|
||||
request, err = s.newRequest("PUT", testAPIFSCacheServer.URL+"/deletebucket-notempty/myobject", 0, nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
client = http.Client{}
|
||||
response, err = client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(response.StatusCode, Equals, http.StatusOK)
|
||||
|
||||
request, err = s.newRequest("DELETE", testAPIFSCacheServer.URL+"/deletebucket-notempty", 0, nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
client = http.Client{}
|
||||
response, err = client.Do(request)
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(response.StatusCode, Equals, http.StatusConflict)
|
||||
}
|
||||
|
||||
func (s *MyAPISuite) TestDeleteObject(c *C) {
|
||||
request, err := s.newRequest("PUT", testAPIFSCacheServer.URL+"/deletebucketobject", 0, nil)
|
||||
c.Assert(err, IsNil)
|
||||
|
|
Loading…
Reference in New Issue