2010-10-12 21:07:36 -04:00
|
|
|
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
|
|
|
|
|
2010-10-29 20:17:02 -04:00
|
|
|
tests("#copy_object('#{@directory.identity}', 'fog_object', '#{@directory.identity}', 'fog_other_object')").succeeds do
|
|
|
|
AWS[:storage].copy_object(@directory.identity, 'fog_object', @directory.identity, 'fog_other_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
@directory.files.get('fog_other_object').destroy
|
|
|
|
|
2010-10-13 16:27:36 -04:00
|
|
|
tests("#get_object('#{@directory.identity}', 'fog_object')").returns(lorem_file.read) do
|
|
|
|
AWS[:storage].get_object(@directory.identity, 'fog_object').body
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_object('#{@directory.identity}', 'fog_object', &block)").returns(lorem_file.read) do
|
|
|
|
data = ''
|
|
|
|
AWS[:storage].get_object(@directory.identity, 'fog_object') do |chunk|
|
|
|
|
data << chunk
|
|
|
|
end
|
|
|
|
data
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#head_object('#{@directory.identity}', 'fog_object')").succeeds do
|
|
|
|
AWS[:storage].head_object(@directory.identity, 'fog_object')
|
|
|
|
end
|
2010-10-12 21:07:36 -04:00
|
|
|
|
|
|
|
tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do
|
|
|
|
AWS[:storage].delete_object(@directory.identity, 'fog_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
tests('failure') do
|
|
|
|
|
2010-10-13 16:27:36 -04:00
|
|
|
tests("#put_object('fognonbucket', 'fog_non_object', lorem_file)").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].put_object('fognonbucket', 'fog_non_object', lorem_file)
|
|
|
|
end
|
|
|
|
|
2010-10-29 20:17:02 -04:00
|
|
|
tests("#copy_object('fognonbucket', 'fog_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].copy_object('fognonbucket', 'fog_object', @directory.identity, 'fog_other_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#copy_object('#{@directory.identity}', 'fog_non_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].copy_object(@directory.identity, 'fog_non_object', @directory.identity, 'fog_other_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#copy_object('#{@directory.identity}', 'fog_object', 'fognonbucket', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].copy_object(@directory.identity, 'fog_object', 'fognonbucket', 'fog_other_object')
|
|
|
|
end
|
|
|
|
|
2010-10-13 16:27:36 -04:00
|
|
|
tests("#get_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].get_object('fognonbucket', 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#get_object('#{@directory.identity}', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].get_object(@directory.identity, 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#head_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].head_object('fognonbucket', 'fog_non_object')
|
|
|
|
end
|
|
|
|
|
|
|
|
tests("#head_object('#{@directory.identity}', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
|
|
|
AWS[:storage].head_object(@directory.identity, 'fog_non_object')
|
2010-10-12 21:07:36 -04:00
|
|
|
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
|
|
|
|
|
2010-10-13 16:27:36 -04:00
|
|
|
end
|