mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|storage|test] Added request tests for put_bucket_versioning and get_bucket_versioning.
This commit is contained in:
parent
a57fdd21dd
commit
dab6b61997
1 changed files with 72 additions and 0 deletions
72
tests/aws/requests/storage/versioning_tests.rb
Normal file
72
tests/aws/requests/storage/versioning_tests.rb
Normal file
|
@ -0,0 +1,72 @@
|
|||
Shindo.tests('Fog::Storage[:aws] | versioning', [:aws]) do
|
||||
tests('success') do
|
||||
tests("#put_bucket_versioning") do
|
||||
@aws_bucket_name = 'fogbuckettests-' + Fog::Mock.random_hex(16)
|
||||
|
||||
before do
|
||||
Fog::Storage[:aws].put_bucket(@aws_bucket_name)
|
||||
end
|
||||
|
||||
after do
|
||||
Fog::Storage[:aws].delete_bucket(@aws_bucket_name)
|
||||
@aws_bucket_name = 'fogbuckettests-' + Fog::Mock.random_hex(16)
|
||||
end
|
||||
|
||||
tests("#put_bucket_versioning('#{@aws_bucket_name}', 'Enabled')").succeeds do
|
||||
Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'Enabled')
|
||||
end
|
||||
|
||||
tests("#put_bucket_versioning('#{@aws_bucket_name}', 'Suspended')").succeeds do
|
||||
Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'Suspended')
|
||||
end
|
||||
end
|
||||
|
||||
tests("#get_bucket_versioning('#{@aws_bucket_name}')") do
|
||||
@aws_bucket_name = 'fogbuckettests-' + Fog::Mock.random_hex(16)
|
||||
|
||||
before do
|
||||
Fog::Storage[:aws].put_bucket(@aws_bucket_name)
|
||||
end
|
||||
|
||||
after do
|
||||
Fog::Storage[:aws].delete_bucket(@aws_bucket_name)
|
||||
@aws_bucket_name = 'fogbuckettests-' + Fog::Mock.random_hex(16)
|
||||
end
|
||||
|
||||
tests("#get_bucket_versioning('#{@aws_bucket_name}') without versioning").returns({}) do
|
||||
Fog::Storage[:aws].get_bucket_versioning(@aws_bucket_name).body['VersioningConfiguration']
|
||||
end
|
||||
|
||||
tests("#get_bucket_versioning('#{@aws_bucket_name}') with versioning enabled").returns('Enabled') do
|
||||
Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'Enabled')
|
||||
Fog::Storage[:aws].get_bucket_versioning(@aws_bucket_name).body['VersioningConfiguration']['Status']
|
||||
end
|
||||
|
||||
tests("#get_bucket_versioning('#{@aws_bucket_name}') with versioning suspended").returns('Suspended') do
|
||||
Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'Enabled')
|
||||
Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'Suspended')
|
||||
Fog::Storage[:aws].get_bucket_versioning(@aws_bucket_name).body['VersioningConfiguration']['Status']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
@aws_bucket_name = 'fogbuckettests-' + Fog::Mock.random_hex(16)
|
||||
Fog::Storage[:aws].put_bucket(@aws_bucket_name)
|
||||
|
||||
tests("#put_bucket_versioning('#{@aws_bucket_name}', 'bad_value')").raises(Excon::Errors::BadRequest) do
|
||||
Fog::Storage[:aws].put_bucket_versioning(@aws_bucket_name, 'bad_value')
|
||||
end
|
||||
|
||||
tests("#put_bucket_versioning('fognonbucket', 'Enabled')").raises(Excon::Errors::NotFound) do
|
||||
Fog::Storage[:aws].put_bucket_versioning('fognonbucket', 'Enabled')
|
||||
end
|
||||
|
||||
tests("#get_bucket_versioning('fognonbucket')").raises(Excon::Errors::NotFound) do
|
||||
Fog::Storage[:aws].get_bucket_versioning('fognonbucket')
|
||||
end
|
||||
end
|
||||
|
||||
# don't keep the bucket around
|
||||
Fog::Storage[:aws].delete_bucket(@aws_bucket_name) rescue nil
|
||||
end
|
Loading…
Reference in a new issue