2009-08-17 15:55:30 -07:00
|
|
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2009-06-07 01:37:54 -07:00
|
|
|
|
2010-09-09 17:50:38 -07:00
|
|
|
describe 'Storage.copy_object' do
|
2009-08-19 19:11:57 -07:00
|
|
|
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')
|
2009-08-19 19:11:57 -07:00
|
|
|
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')
|
2009-08-19 19:11:57 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return proper attributes' do
|
2010-09-09 17:50:38 -07:00
|
|
|
actual = AWS[:storage].copy_object(
|
2009-08-19 19:11:57 -07:00
|
|
|
'fogcopyobjectsource', 'fog_copy_object_source',
|
2009-08-16 13:31:36 -07:00
|
|
|
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
|
|
|
)
|
2009-08-19 19:11:57 -07:00
|
|
|
actual.status.should == 200
|
|
|
|
actual.body['ETag'].should be_a(String)
|
|
|
|
actual.body['LastModified'].should be_a(Time)
|
|
|
|
end
|
2009-08-16 13:31:36 -07:00
|
|
|
|
|
|
|
end
|
2009-08-19 19:11:57 -07:00
|
|
|
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(
|
2009-08-19 19:11:57 -07:00
|
|
|
'fognotabucket', 'fog_copy_object_source',
|
|
|
|
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
|
|
|
)
|
2009-10-31 12:26:49 -07:00
|
|
|
}.should raise_error(Excon::Errors::NotFound)
|
2009-08-19 19:11:57 -07:00
|
|
|
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(
|
2009-08-19 19:11:57 -07:00
|
|
|
'fogcopyobjectsource', 'fog_not_an_object',
|
|
|
|
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
|
|
|
)
|
2009-10-31 12:26:49 -07:00
|
|
|
}.should raise_error(Excon::Errors::NotFound)
|
2009-08-19 19:11:57 -07:00
|
|
|
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(
|
2009-08-19 19:11:57 -07:00
|
|
|
'fogcopyobjectsource', 'fog_copy_object_source',
|
|
|
|
'fognotabucket', 'fog_copy_object_destination'
|
|
|
|
)
|
2009-10-31 12:26:49 -07:00
|
|
|
}.should raise_error(Excon::Errors::NotFound)
|
2009-08-19 19:11:57 -07:00
|
|
|
end
|
2009-08-16 13:31:36 -07:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2009-08-19 19:11:57 -07:00
|
|
|
end
|