Sha256: d573f389799cd0400cda700507aff01015c2b8b072ee9e102b707b865844144d

Contents?: true

Size: 1.92 KB

Versions: 27

Compression:

Stored size: 1.92 KB

Contents

require File.dirname(__FILE__) + '/../../../spec_helper'

describe 'S3.copy_object' do
  describe 'success' do

    before(:each) do
      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

    after(:each) do
      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',
        '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 {
        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

  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
fog-0.0.29 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.28 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.27 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.26 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.25 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.24 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.23 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.22 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.21 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.20 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.19 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.18 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.17 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.16 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.15 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.14 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.13 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.12 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.11 spec/aws/requests/s3/copy_object_spec.rb
fog-0.0.10 spec/aws/requests/s3/copy_object_spec.rb