Sha256: 4ca26d37db440ad4beb9f4f70cba289a7e26e3bbe8eaf99cea702c369a1e2866

Contents?: true

Size: 1.98 KB

Versions: 14

Compression:

Stored size: 1.98 KB

Contents

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

describe 'Storage.copy_object' do
  describe 'success' do

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

    after(:each) do
      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
      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 {
        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 {
        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 {
        AWS[:storage].copy_object(
          'fogcopyobjectsource', 'fog_copy_object_source',
          'fognotabucket', 'fog_copy_object_destination'
        )
      }.should raise_error(Excon::Errors::NotFound)
    end

  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-0.3.13 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.12 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.11 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.10 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.9 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.8 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.7 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.6 spec/aws/requests/storage/copy_object_spec.rb
fog-0.3.5 spec/aws/requests/s3/copy_object_spec.rb
fog-0.3.4 spec/aws/requests/s3/copy_object_spec.rb
fog-0.3.3 spec/aws/requests/s3/copy_object_spec.rb
fog-0.3.2 spec/aws/requests/s3/copy_object_spec.rb
fog-0.3.1 spec/aws/requests/s3/copy_object_spec.rb
fog-0.3.0 spec/aws/requests/s3/copy_object_spec.rb