Sha256: 16000673b410fe6f503629b474be8864ad46d31aee7f1d5cb175bdf9fb1318a2

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

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

describe 'S3.copy_object' do

  before(:all) do
    @s3 = Fog::AWS::S3.gen
    @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(:all) 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

  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geemus-fog-0.0.1 spec/aws/requests/s3/copy_object_spec.rb
geemus-fog-0.0.3 spec/aws/requests/s3/copy_object_spec.rb