2010-10-12 20:40:02 -04:00
|
|
|
Shindo.tests('AWS::Storage | bucket requests', ['aws']) do
|
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
2010-10-29 20:17:02 -04:00
|
|
|
@bucket_format = {
|
2010-11-30 19:43:28 -05:00
|
|
|
'CommonPrefixes' => [],
|
|
|
|
'IsTruncated' => Fog::Boolean,
|
|
|
|
'Marker' => NilClass,
|
|
|
|
'MaxKeys' => Integer,
|
|
|
|
'Name' => String,
|
|
|
|
'Prefix' => NilClass,
|
2010-10-29 20:17:02 -04:00
|
|
|
'Contents' => [{
|
|
|
|
'ETag' => String,
|
|
|
|
'Key' => String,
|
|
|
|
'LastModified' => Time,
|
|
|
|
'Owner' => {
|
|
|
|
'DisplayName' => String,
|
|
|
|
'ID' => String
|
|
|
|
},
|
|
|
|
'Size' => Integer,
|
|
|
|
'StorageClass' => String
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
@service_format = {
|
|
|
|
'Buckets' => [{
|
|
|
|
'CreationDate' => Time,
|
|
|
|
'Name' => String,
|
|
|
|
}],
|
|
|
|
'Owner' => {
|
2010-10-12 20:40:02 -04:00
|
|
|
'DisplayName' => String,
|
|
|
|
'ID' => String
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
tests("#put_bucket('fogbuckettests')").succeeds do
|
|
|
|
AWS[:storage].put_bucket('fogbuckettests')
|
2010-10-12 20:40:02 -04:00
|
|
|
end
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
tests("#get_service").formats(@service_format) do
|
2010-10-12 20:40:02 -04:00
|
|
|
AWS[:storage].get_service.body
|
|
|
|
end
|
|
|
|
|
2010-10-29 20:17:02 -04:00
|
|
|
file = AWS[:storage].directories.get('fogbuckettests').files.create(:body => 'y', :key => 'x')
|
|
|
|
|
|
|
|
tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do
|
|
|
|
AWS[:storage].get_bucket('fogbuckettests').body
|
|
|
|
end
|
|
|
|
|
|
|
|
file.destroy
|
|
|
|
|
|
|
|
tests("#get_bucket_location('fogbuckettests)").formats('LocationConstraint' => NilClass) do
|
|
|
|
AWS[:storage].get_bucket_location('fogbuckettests').body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_request_payment('fogbuckettests')").formats('Payer' => String) do
|
|
|
|
AWS[:storage].get_request_payment('fogbuckettests').body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#put_request_payment('fogbuckettests', 'Requester')").succeeds do
|
|
|
|
AWS[:storage].put_request_payment('fogbuckettests', 'Requester')
|
|
|
|
end
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
tests("#delete_bucket('fogbuckettests')").succeeds do
|
|
|
|
AWS[:storage].delete_bucket('fogbuckettests')
|
2010-10-12 20:40:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
tests("#delete_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].delete_bucket('fognonbucket')
|
2010-10-12 20:40:02 -04:00
|
|
|
end
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
@bucket = AWS[:storage].directories.create(:key => 'fognonempty')
|
2010-10-12 20:40:02 -04:00
|
|
|
@file = @bucket.files.create(:key => 'foo', :body => 'bar')
|
|
|
|
|
2010-10-12 21:07:36 -04:00
|
|
|
tests("#delete_bucket('fognonempty')").raises(Excon::Errors::Conflict) do
|
|
|
|
AWS[:storage].delete_bucket('fognonempty')
|
2010-10-12 20:40:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@file.destroy
|
|
|
|
@bucket.destroy
|
|
|
|
|
2010-10-29 20:17:02 -04:00
|
|
|
tests("#get_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].get_bucket('fognonbucket')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_bucket_location('fognonbucket')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].get_bucket_location('fognonbucket')
|
|
|
|
end
|
|
|
|
|
2010-11-10 16:58:50 -05:00
|
|
|
tests("#get_request_payment('fognonbucket')").raises(Excon::Errors::NotFound) do
|
2010-10-29 20:17:02 -04:00
|
|
|
AWS[:storage].get_request_payment('fognonbucket')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#put_request_payment('fognonbucket', 'Requester')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].put_request_payment('fognonbucket', 'Requester')
|
|
|
|
end
|
|
|
|
|
2010-10-12 20:40:02 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|