Skip to content

Commit

Permalink
Add Integration Tests for Resource Copy
Browse files Browse the repository at this point in the history
Will test that we properly copy objects with spaces, end to end.
  • Loading branch information
awood45 committed Mar 29, 2016
1 parent 7dd105a commit a23f0b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 6 additions & 0 deletions aws-sdk-resources/features/s3/multipart_copy.feature
Expand Up @@ -10,3 +10,9 @@ Feature: Managed multipart copies
Given a "source_bucket" is set in cfg["s3"]["large_object"]["bucket"]
And a "source_key" is set in cfg["s3"]["large_object"]["key"]
Then I should be able to multipart copy the object to a different bucket

Scenario: Copy object with space character
Given I create a bucket
And I have a 1MB file
And I upload the file to the "test object" object
Then I should be able to copy the object
18 changes: 8 additions & 10 deletions aws-sdk-resources/features/s3/step_definitions.rb
Expand Up @@ -8,16 +8,7 @@

After("@s3") do
@created_buckets.each do |bucket|
# TODO : provide a Bucket#delete! method
loop do
objects = bucket.client.list_object_versions(bucket: bucket.name)
objects = objects.data.versions.map do |v|
{ key: v.key, version_id: v.version_id }
end
break if objects.empty?
bucket.client.delete_objects(bucket: bucket.name, delete: { objects: objects })
end
bucket.delete
bucket.delete!
end
end

Expand Down Expand Up @@ -130,3 +121,10 @@
target_object.copy_from("#{@source_bucket}/#{@source_key}", multipart_copy: true)
expect(ApiCallTracker.called_operations).to include(:create_multipart_upload)
end

Then(/^I should be able to copy the object$/) do
target_bucket = @s3.bucket(@bucket_name)
target_object = target_bucket.object("test object-copy")
target_object.copy_from("#{@bucket_name}/test object")
expect(ApiCallTracker.called_operations).to include(:copy_object)
end

0 comments on commit a23f0b1

Please sign in to comment.