1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/hp/requests/storage/object_tests.rb

64 lines
2.1 KiB
Ruby
Raw Normal View History

2012-04-02 15:31:29 -04:00
Shindo.tests('Fog::Storage[:hp] | object requests', [:hp]) do
@directory = Fog::Storage[:hp].directories.create(:key => 'fogobjecttests')
@dir_name = @directory.identity
tests('success') do
tests("#put_object(#{@dir_name}, 'fog_object')").succeeds do
Fog::Storage[:hp].put_object(@dir_name, 'fog_object', lorem_file)
end
tests("#get_object(#{@dir_name}, 'fog_object')").succeeds do
Fog::Storage[:hp].get_object(@dir_name, 'fog_object')
end
tests("#get_object(#{@dir_name}, 'fog_object', &block)").returns(lorem_file.read) do
data = ''
Fog::Storage[:hp].get_object(@dir_name, 'fog_object') do |chunk, remaining_bytes, total_bytes|
data << chunk
end
data
end
tests("#head_object(#{@dir_name}, 'fog_object')").succeeds do
Fog::Storage[:hp].head_object(@dir_name, 'fog_object')
end
tests("#delete_object(#{@dir_name}, 'fog_object')").succeeds do
Fog::Storage[:hp].delete_object(@dir_name, 'fog_object')
end
end
tests('failure') do
tests("#get_object(#{@dir_name}, 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
Fog::Storage[:hp].get_object(@dir_name, 'fog_non_object')
end
tests("#get_object('fognoncontainer', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
Fog::Storage[:hp].get_object('fognoncontainer', 'fog_non_object')
end
tests("#head_object(#{@dir_name}, 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
Fog::Storage[:hp].head_object(@dir_name, 'fog_non_object')
end
tests("#head_object('fognoncontainer', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
Fog::Storage[:hp].head_object('fognoncontainer', 'fog_non_object')
end
tests("#delete_object(#{@dir_name}, 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
Fog::Storage[:hp].delete_object(@dir_name, 'fog_non_object')
end
tests("#delete_object('fognoncontainer', 'fog_non_object')").raises(Fog::Storage::HP::NotFound) do
Fog::Storage[:hp].delete_object('fognoncontainer', 'fog_non_object')
end
end
@directory.destroy
end