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:
commit
eb4be1cf72
2 changed files with 14 additions and 2 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue