1
0
Fork 0
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:
James Rucker 2015-08-24 16:27:12 -07:00
parent 822aedb108
commit f46a94b1db
2 changed files with 14 additions and 2 deletions

View file

@ -59,9 +59,9 @@ DATA
else else
bucket['LocationConstraint'] = nil bucket['LocationConstraint'] = nil
end end
if !self.data[:buckets][bucket_name] || self.region == 'us-east-1' if !self.data[:buckets][bucket_name]
self.data[:buckets][bucket_name] = bucket self.data[:buckets][bucket_name] = bucket
else elsif self.region != 'us-east-1'
response.status = 409 response.status = 409
raise(Excon::Errors.status_error({:expects => 200}, response)) raise(Excon::Errors.status_error({:expects => 200}, response))
end end

View file

@ -56,6 +56,18 @@ Shindo.tests('Fog::Storage[:aws] | bucket requests', ["aws"]) do
end end
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 tests("#get_service").formats(@service_format) do
Fog::Storage[:aws].get_service.body Fog::Storage[:aws].get_service.body
end end