2009-08-17 18:55:30 -04:00
|
|
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2009-06-07 04:37:54 -04:00
|
|
|
|
|
|
|
describe 'S3.copy_object' do
|
2009-08-19 22:11:57 -04:00
|
|
|
describe 'success' do
|
|
|
|
|
2009-08-19 23:32:57 -04:00
|
|
|
before(:each) do
|
2009-08-19 22:11:57 -04:00
|
|
|
s3.put_bucket('fogcopyobjectsource')
|
|
|
|
file = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
|
|
|
s3.put_object('fogcopyobjectsource', 'fog_copy_object_source', file)
|
|
|
|
s3.put_bucket('fogcopyobjectdestination')
|
|
|
|
end
|
|
|
|
|
2009-08-19 23:32:57 -04:00
|
|
|
after(:each) do
|
2009-08-19 22:11:57 -04:00
|
|
|
s3.delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
|
|
|
|
s3.delete_bucket('fogcopyobjectdestination')
|
|
|
|
s3.delete_object('fogcopyobjectsource', 'fog_copy_object_source')
|
|
|
|
s3.delete_bucket('fogcopyobjectsource')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should return proper attributes' do
|
|
|
|
actual = s3.copy_object(
|
|
|
|
'fogcopyobjectsource', 'fog_copy_object_source',
|
2009-08-16 16:31:36 -04:00
|
|
|
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
|
|
|
)
|
2009-08-19 22:11:57 -04:00
|
|
|
actual.status.should == 200
|
|
|
|
actual.body['ETag'].should be_a(String)
|
|
|
|
actual.body['LastModified'].should be_a(Time)
|
|
|
|
end
|
2009-08-16 16:31:36 -04:00
|
|
|
|
|
|
|
end
|
2009-08-19 22:11:57 -04:00
|
|
|
describe 'failure' do
|
|
|
|
|
|
|
|
it 'should raise a NotFound error if the source_bucket does not exist' do
|
|
|
|
lambda {
|
|
|
|
s3.copy_object(
|
|
|
|
'fognotabucket', 'fog_copy_object_source',
|
|
|
|
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
|
|
|
)
|
|
|
|
}.should raise_error(Fog::Errors::NotFound)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should raise a NotFound error if the source_object does not exist' do
|
|
|
|
lambda {
|
|
|
|
s3.copy_object(
|
|
|
|
'fogcopyobjectsource', 'fog_not_an_object',
|
|
|
|
'fogcopyobjectdestination', 'fog_copy_object_destination'
|
|
|
|
)
|
|
|
|
}.should raise_error(Fog::Errors::NotFound)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should raise a NotFound error if the target_bucket does not exist' do
|
|
|
|
lambda {
|
|
|
|
s3.copy_object(
|
|
|
|
'fogcopyobjectsource', 'fog_copy_object_source',
|
|
|
|
'fognotabucket', 'fog_copy_object_destination'
|
|
|
|
)
|
|
|
|
}.should raise_error(Fog::Errors::NotFound)
|
|
|
|
end
|
2009-08-16 16:31:36 -04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2009-08-19 22:11:57 -04:00
|
|
|
end
|