2011-06-15 17:26:43 -04:00
|
|
|
Shindo.tests('Fog::Storage[:google] | bucket requests', [:google]) do
|
2010-11-10 16:58:50 -05:00
|
|
|
|
|
|
|
tests('success') do
|
|
|
|
|
|
|
|
@bucket_format = {
|
2010-12-08 19:08:58 -05:00
|
|
|
'CommonPrefixes' => [],
|
|
|
|
'IsTruncated' => Fog::Boolean,
|
|
|
|
'Marker' => NilClass,
|
|
|
|
'Name' => String,
|
|
|
|
'Prefix' => NilClass,
|
|
|
|
'Contents' => [{
|
2010-11-10 16:58:50 -05:00
|
|
|
'ETag' => String,
|
|
|
|
'Key' => String,
|
|
|
|
'LastModified' => Time,
|
|
|
|
'Owner' => {
|
|
|
|
'DisplayName' => String,
|
|
|
|
'ID' => String
|
|
|
|
},
|
|
|
|
'Size' => Integer,
|
2010-12-08 19:08:58 -05:00
|
|
|
'StorageClass' => String
|
2010-11-10 16:58:50 -05:00
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
|
|
|
@service_format = {
|
|
|
|
'Buckets' => [{
|
|
|
|
'CreationDate' => Time,
|
|
|
|
'Name' => String,
|
|
|
|
}],
|
|
|
|
'Owner' => {
|
|
|
|
'ID' => String
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tests("#put_bucket('fogbuckettests')").succeeds do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].put_bucket('fogbuckettests')
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_service").formats(@service_format) do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].get_service.body
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
2011-06-15 17:26:43 -04:00
|
|
|
file = Fog::Storage[:google].directories.get('fogbuckettests').files.create(:body => 'y', :key => 'x')
|
2010-11-10 16:58:50 -05:00
|
|
|
|
|
|
|
tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].get_bucket('fogbuckettests').body
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
file.destroy
|
|
|
|
|
|
|
|
tests("#delete_bucket('fogbuckettests')").succeeds do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].delete_bucket('fogbuckettests')
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
|
|
|
tests("#delete_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].delete_bucket('fognonbucket')
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
2011-06-15 17:26:43 -04:00
|
|
|
@bucket = Fog::Storage[:google].directories.create(:key => 'fognonempty')
|
2010-11-10 16:58:50 -05:00
|
|
|
@file = @bucket.files.create(:key => 'foo', :body => 'bar')
|
|
|
|
|
|
|
|
tests("#delete_bucket('fognonempty')").raises(Excon::Errors::Conflict) do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].delete_bucket('fognonempty')
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
@file.destroy
|
|
|
|
@bucket.destroy
|
|
|
|
|
|
|
|
tests("#get_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
|
2011-06-15 17:26:43 -04:00
|
|
|
Fog::Storage[:google].get_bucket('fognonbucket')
|
2010-11-10 16:58:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|