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

62 lines
2 KiB
Ruby
Raw Normal View History

2009-08-17 15:55:30 -07:00
require File.dirname(__FILE__) + '/../../../spec_helper'
2010-09-09 17:50:38 -07:00
describe 'Storage.copy_object' do
describe 'success' do
2009-08-19 20:32:57 -07:00
before(:each) do
2010-09-09 17:50:38 -07:00
AWS[:storage].put_bucket('fogcopyobjectsource')
AWS[:storage].put_object('fogcopyobjectsource', 'fog_copy_object_source', lorem_file)
AWS[:storage].put_bucket('fogcopyobjectdestination')
end
2009-08-19 20:32:57 -07:00
after(:each) do
2010-09-09 17:50:38 -07:00
AWS[:storage].delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
AWS[:storage].delete_bucket('fogcopyobjectdestination')
AWS[:storage].delete_object('fogcopyobjectsource', 'fog_copy_object_source')
AWS[:storage].delete_bucket('fogcopyobjectsource')
end
it 'should return proper attributes' do
2010-09-09 17:50:38 -07:00
actual = AWS[:storage].copy_object(
'fogcopyobjectsource', 'fog_copy_object_source',
'fogcopyobjectdestination', 'fog_copy_object_destination'
)
actual.status.should == 200
actual.body['ETag'].should be_a(String)
actual.body['LastModified'].should be_a(Time)
end
end
describe 'failure' do
it 'should raise a NotFound error if the source_bucket does not exist' do
lambda {
2010-09-09 17:50:38 -07:00
AWS[:storage].copy_object(
'fognotabucket', 'fog_copy_object_source',
'fogcopyobjectdestination', 'fog_copy_object_destination'
)
}.should raise_error(Excon::Errors::NotFound)
end
it 'should raise a NotFound error if the source_object does not exist' do
lambda {
2010-09-09 17:50:38 -07:00
AWS[:storage].copy_object(
'fogcopyobjectsource', 'fog_not_an_object',
'fogcopyobjectdestination', 'fog_copy_object_destination'
)
}.should raise_error(Excon::Errors::NotFound)
end
it 'should raise a NotFound error if the target_bucket does not exist' do
lambda {
2010-09-09 17:50:38 -07:00
AWS[:storage].copy_object(
'fogcopyobjectsource', 'fog_copy_object_source',
'fognotabucket', 'fog_copy_object_destination'
)
}.should raise_error(Excon::Errors::NotFound)
end
end
end