1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

Merge pull request #174 from jgr/mock-create-bucket-preserves-existing

Mocked put_bucket no longer clobbers existing bucket
This commit is contained in:
Wesley Beary 2015-08-25 08:45:21 -05:00
commit eb4be1cf72
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