mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Mocked put_bucket no longer clobbers existing bucket
In the default region (us-east-1), put_bucket will return an existing bucket, rather than throw a BucketAlreadyOwnedByYou error. Changed the mock to reflect this behavior.
This commit is contained in:
parent
822aedb108
commit
f46a94b1db
2 changed files with 14 additions and 2 deletions
|
@ -59,9 +59,9 @@ DATA
|
|||
else
|
||||
bucket['LocationConstraint'] = nil
|
||||
end
|
||||
if !self.data[:buckets][bucket_name] || self.region == 'us-east-1'
|
||||
if !self.data[:buckets][bucket_name]
|
||||
self.data[:buckets][bucket_name] = bucket
|
||||
else
|
||||
elsif self.region != 'us-east-1'
|
||||
response.status = 409
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
|
|
|
@ -56,6 +56,18 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', ["aws"]) do
|
|||
end
|
||||
end
|
||||
|
||||
tests('put existing bucket - default region - preserves files') do
|
||||
Fog::Storage[:aws].put_bucket(@aws_bucket_name)
|
||||
test_key = Fog::Storage[:aws].directories.get(@aws_bucket_name).files.create(:body => 'test', :key => 'test/key')
|
||||
Fog::Storage[:aws].put_bucket(@aws_bucket_name)
|
||||
|
||||
tests(".body['Contents'].first['Key']").returns('test/key') do
|
||||
Fog::Storage[:aws].get_bucket(@aws_bucket_name).body['Contents'].first['Key']
|
||||
end
|
||||
|
||||
test_key.destroy
|
||||
end
|
||||
|
||||
tests("#get_service").formats(@service_format) do
|
||||
Fog::Storage[:aws].get_service.body
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue