Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[aws|storage] continuing to flesh out tests

  • Loading branch information...
commit 46fdab47e5cf89f1cef9ad7f95c17279d5310457 1 parent 4068db6
@geemus geemus authored
View
1  lib/fog/aws/models/storage/file.rb
@@ -8,6 +8,7 @@ class File < Fog::Model
identity :key, :aliases => 'Key'
+ attr_writer :body
attribute :content_length, :aliases => 'Content-Length'
attribute :content_type, :aliases => 'Content-Type'
attribute :etag, :aliases => ['Etag', 'ETag']
View
1  lib/fog/google/models/storage/file.rb
@@ -8,6 +8,7 @@ class File < Fog::Model
identity :key, :aliases => 'Key'
+ attr_writer :body
attribute :content_length, :aliases => 'Content-Length'
attribute :content_type, :aliases => 'Content-Type'
attribute :etag, :aliases => ['Etag', 'ETag']
View
1  lib/fog/local/models/storage/file.rb
@@ -8,6 +8,7 @@ class File < Fog::Model
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'
View
1  lib/fog/rackspace/models/storage/file.rb
@@ -8,6 +8,7 @@ class File < Fog::Model
identity :key, :aliases => 'Key'
+ attr_writer :body
attribute :content_length, :aliases => 'Content-Length'
attribute :content_type, :aliases => 'Content-Type'
attribute :etag, :aliases => 'Etag'
View
36 spec/aws/requests/storage/delete_object_spec.rb
@@ -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
View
43 spec/aws/requests/storage/put_object_spec.rb
@@ -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
View
30 tests/aws/requests/storage/bucket_tests.rb
@@ -2,40 +2,42 @@
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
View
33 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
View
4 tests/helper.rb
@@ -16,6 +16,10 @@ module Boolean
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
View
1  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.
Please sign in to comment.
Something went wrong with that request. Please try again.