Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[aws|storage] continuing to flesh out tests
  • Loading branch information
geemus committed Oct 13, 2010
1 parent 4068db6 commit 46fdab4
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 93 deletions.
1 change: 1 addition & 0 deletions lib/fog/aws/models/storage/file.rb
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions lib/fog/google/models/storage/file.rb
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions lib/fog/local/models/storage/file.rb
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions lib/fog/rackspace/models/storage/file.rb
Expand Up @@ -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'
Expand Down
36 changes: 0 additions & 36 deletions spec/aws/requests/storage/delete_object_spec.rb

This file was deleted.

43 changes: 0 additions & 43 deletions spec/aws/requests/storage/put_object_spec.rb

This file was deleted.

30 changes: 16 additions & 14 deletions tests/aws/requests/storage/bucket_tests.rb
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions 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
4 changes: 4 additions & 0 deletions tests/helper.rb
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions 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.

0 comments on commit 46fdab4

Please sign in to comment.