diff --git a/lib/fog/aws/models/storage/file.rb b/lib/fog/aws/models/storage/file.rb index d7c9eb095..a47f8579f 100644 --- a/lib/fog/aws/models/storage/file.rb +++ b/lib/fog/aws/models/storage/file.rb @@ -8,6 +8,7 @@ module Fog identity :key, :aliases => 'Key' + attr_writer :body attribute :content_length, :aliases => 'Content-Length' attribute :content_type, :aliases => 'Content-Type' attribute :etag, :aliases => ['Etag', 'ETag'] diff --git a/lib/fog/google/models/storage/file.rb b/lib/fog/google/models/storage/file.rb index acce63a51..16504d2df 100644 --- a/lib/fog/google/models/storage/file.rb +++ b/lib/fog/google/models/storage/file.rb @@ -8,6 +8,7 @@ module Fog identity :key, :aliases => 'Key' + attr_writer :body attribute :content_length, :aliases => 'Content-Length' attribute :content_type, :aliases => 'Content-Type' attribute :etag, :aliases => ['Etag', 'ETag'] diff --git a/lib/fog/local/models/storage/file.rb b/lib/fog/local/models/storage/file.rb index 11fa1f31e..054721395 100644 --- a/lib/fog/local/models/storage/file.rb +++ b/lib/fog/local/models/storage/file.rb @@ -8,6 +8,7 @@ module Fog identity :key, :aliases => 'Key' + attr_writer :body attribute :content_length, :aliases => 'Content-Length' # attribute :content_type, :aliases => 'Content-Type' attribute :last_modified, :aliases => 'Last-Modified' diff --git a/lib/fog/rackspace/models/storage/file.rb b/lib/fog/rackspace/models/storage/file.rb index 1e769949b..525bf0dd1 100644 --- a/lib/fog/rackspace/models/storage/file.rb +++ b/lib/fog/rackspace/models/storage/file.rb @@ -8,6 +8,7 @@ module Fog identity :key, :aliases => 'Key' + attr_writer :body attribute :content_length, :aliases => 'Content-Length' attribute :content_type, :aliases => 'Content-Type' attribute :etag, :aliases => 'Etag' diff --git a/spec/aws/requests/storage/delete_object_spec.rb b/spec/aws/requests/storage/delete_object_spec.rb deleted file mode 100644 index 10bfd7da4..000000000 --- a/spec/aws/requests/storage/delete_object_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.delete_object' do - describe 'success' do - - before(:each) do - AWS[:storage].put_bucket('fogdeleteobject') - AWS[:storage].put_object('fogdeleteobject', 'fog_delete_object', lorem_file) - end - - after(:each) do - AWS[:storage].delete_bucket('fogdeleteobject') - end - - it 'should return proper attributes' do - actual = AWS[:storage].delete_object('fogdeleteobject', 'fog_delete_object') - actual.status.should == 204 - end - - end - describe 'failure' do - - it 'should raise a NotFound error if the bucket does not exist' do - lambda { - AWS[:storage].delete_object('fognotabucket', 'fog_delete_object') - }.should raise_error(Excon::Errors::NotFound) - end - - it 'should not raise an error if the object does not exist' do - AWS[:storage].put_bucket('fogdeleteobject') - AWS[:storage].delete_object('fogdeleteobject', 'fog_not_an_object') - AWS[:storage].delete_bucket('fogdeleteobject') - end - - end -end diff --git a/spec/aws/requests/storage/put_object_spec.rb b/spec/aws/requests/storage/put_object_spec.rb deleted file mode 100644 index 53dc417cf..000000000 --- a/spec/aws/requests/storage/put_object_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require File.dirname(__FILE__) + '/../../../spec_helper' - -describe 'Storage.put_object' do - describe 'success' do - - before(:each) do - AWS[:storage].put_bucket('fogputobject') - @response = AWS[:storage].put_object('fogputobject', 'fog_put_object', lorem_file) - end - - after(:each) do - AWS[:storage].delete_object('fogputobject', 'fog_put_object') - AWS[:storage].delete_bucket('fogputobject') - end - - it 'should return proper attributes' do - @response.status.should == 200 - end - - it 'should not raise an error if the object already exists' do - actual = AWS[:storage].put_object('fogputobject', 'fog_put_object', lorem_file) - actual.status.should == 200 - end - - end - describe 'failure' do - - it 'should raise a NotFound error if the bucket does not exist' do - lambda { - AWS[:storage].put_object('fognotabucket', 'fog_put_object', lorem_file) - }.should raise_error(Excon::Errors::NotFound) - end - - it 'should not raise an error if the object already exists' do - AWS[:storage].put_bucket('fogputobject') - AWS[:storage].put_object('fogputobject', 'fog_put_object', lorem_file) - AWS[:storage].put_object('fogputobject', 'fog_put_object', lorem_file) - AWS[:storage].delete_object('fogputobject', 'fog_put_object') - AWS[:storage].delete_bucket('fogputobject') - end - - end -end diff --git a/tests/aws/requests/storage/bucket_tests.rb b/tests/aws/requests/storage/bucket_tests.rb index 7cc0fe3e6..99ec4252a 100644 --- a/tests/aws/requests/storage/bucket_tests.rb +++ b/tests/aws/requests/storage/bucket_tests.rb @@ -2,40 +2,42 @@ Shindo.tests('AWS::Storage | bucket requests', ['aws']) do tests('success') do - @buckets_format = { - 'CreationDate' => Time, - 'Name' => String, - 'Owner' => { + @service_format = { + 'Buckets' => [{ + 'CreationDate' => Time, + 'Name' => String, + }], + 'Owner' => { 'DisplayName' => String, 'ID' => String } } - tests("#put_bucket('fog_bucket')").succeeds do - AWS[:storage].put_bucket('fog_bucket') + tests("#put_bucket('fogbuckettests')").succeeds do + AWS[:storage].put_bucket('fogbuckettests') end - tests("#get_service").formats('Buckets' => [@bucket_format]) do + tests("#get_service").formats(@service_format) do AWS[:storage].get_service.body end - tests("#delete_bucket('fog_bucket')").succeeds do - AWS[:storage].delete_bucket('fog_bucket') + tests("#delete_bucket('fogbuckettests')").succeeds do + AWS[:storage].delete_bucket('fogbuckettests') end end tests('failure') do - tests("#delete_bucket('fog_not_a_bucket')").raises(Fog::Errors::NotFound) do - AWS[:storage].delete_bucket('fog_not_a_bucket') + tests("#delete_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do + AWS[:storage].delete_bucket('fognonbucket') end - @bucket = AWS[:storage].directories.create('fog_nonempty') + @bucket = AWS[:storage].directories.create(:key => 'fognonempty') @file = @bucket.files.create(:key => 'foo', :body => 'bar') - tests("#delete_bucket('fog_nonempty')").raises(Fog::Errors::Conflict) do - AWS[:storage].delete_bucket('fog_nonempty') + tests("#delete_bucket('fognonempty')").raises(Excon::Errors::Conflict) do + AWS[:storage].delete_bucket('fognonempty') end @file.destroy diff --git a/tests/aws/requests/storage/object_tests.rb b/tests/aws/requests/storage/object_tests.rb new file mode 100644 index 000000000..cf0cc6119 --- /dev/null +++ b/tests/aws/requests/storage/object_tests.rb @@ -0,0 +1,33 @@ +Shindo.tests('AWS::Storage | object requests', ['aws']) do + + @directory = AWS[:storage].directories.create(:key => 'fogobjecttests') + + tests('success') do + + tests("#put_object('#{@directory.identity}', 'fog_object', lorem_file)").succeeds do + AWS[:storage].put_object(@directory.identity, 'fog_object', lorem_file) + end + + tests("#get_object") + + tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do + AWS[:storage].delete_object(@directory.identity, 'fog_object') + end + + end + + tests('failure') do + + tests("#put_object('fognonbucket', 'fog_object', lorem_file)").raises(Excon::Errors::NotFound) do + AWS[:storage].put_object('fognonbucket', 'fog_object', lorem_file) + end + + tests("#delete_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do + AWS[:storage].delete_object('fognonbucket', 'fog_non_object') + end + + end + + @directory.destroy + +end \ No newline at end of file diff --git a/tests/helper.rb b/tests/helper.rb index 4ce3eba39..3e40f4c06 100644 --- a/tests/helper.rb +++ b/tests/helper.rb @@ -16,6 +16,10 @@ end FalseClass.send(:include, Fog::Boolean) TrueClass.send(:include, Fog::Boolean) +def lorem_file + File.open(File.dirname(__FILE__) + '/lorem.txt', 'r') +end + module Shindo class Tests diff --git a/tests/lorem.txt b/tests/lorem.txt new file mode 100644 index 000000000..e8b7adfc7 --- /dev/null +++ b/tests/lorem.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file