Sha256: 7e49af894ca77f585c8a7c8c28a99693a56049b5c281e73da3b1bb5ebc9ab644

Contents?: true

Size: 1.93 KB

Versions: 102

Compression:

Stored size: 1.93 KB

Contents

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

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

    before(:each) do
      AWS[:s3].put_bucket('fogcopyobjectsource')
      AWS[:s3].put_object('fogcopyobjectsource', 'fog_copy_object_source', lorem_file)
      AWS[:s3].put_bucket('fogcopyobjectdestination')
    end

    after(:each) do
      AWS[:s3].delete_object('fogcopyobjectdestination', 'fog_copy_object_destination')
      AWS[:s3].delete_bucket('fogcopyobjectdestination')
      AWS[:s3].delete_object('fogcopyobjectsource', 'fog_copy_object_source')
      AWS[:s3].delete_bucket('fogcopyobjectsource')
    end

    it 'should return proper attributes' do
      actual = AWS[: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 {
        AWS[:s3].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 {
        AWS[:s3].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 {
        AWS[:s3].copy_object(
          'fogcopyobjectsource', 'fog_copy_object_source',
          'fognotabucket', 'fog_copy_object_destination'
        )
      }.should raise_error(Excon::Errors::NotFound)
    end

  end

end

Version data entries

102 entries across 102 versions & 2 rubygems

Version Path
fog-0.2.30 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.28 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.27 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.26 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.25 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.24 spec/aws/requests/s3/copy_object_spec.rb
tecnh-fog-0.2.23.vpc spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.23 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.22 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.21 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.20 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.19 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.18 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.17 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.16 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.15 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.14 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.13 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.12 spec/aws/requests/s3/copy_object_spec.rb
fog-0.2.11 spec/aws/requests/s3/copy_object_spec.rb