Skip to content

Commit

Permalink
return aws response object on success
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Beaton committed Aug 22, 2016
1 parent a33f4bf commit 56714e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/rain_forest/cloud_front.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ def create_invalidation(distribution_id, invalidate_paths_array, caller_referenc
}
}

@client.create_invalidation(distribution_id, parameters)
resp = @client.create_invalidation(distribution_id, parameters)

return true, resp
rescue Exception => e
return false, e.message
end

return true, nil
end
end
end
8 changes: 5 additions & 3 deletions spec/rain_forest/cloud_front_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
before do
expect(SecureRandom).to receive(:hex).with(16).and_return("A_RANDOM_CALLER_REFERENCE")
end

let(:aws_response_object){double("AWS Response Object")}

it "created an invalidation" do
expected_parameters = {
Expand All @@ -79,11 +81,11 @@
}
}

expect(client).to receive(:create_invalidation).with("DISTRIBUTION_ID", expected_parameters)
expect(client).to receive(:create_invalidation).with("DISTRIBUTION_ID", expected_parameters).and_return(aws_response_object)

success, message = RainForest::CloudFront.create_invalidation("DISTRIBUTION_ID", ["FIRST_PATH", "SECOND_PATH", "THIRD_PATH"])
success, message_or_object = RainForest::CloudFront.create_invalidation("DISTRIBUTION_ID", ["FIRST_PATH", "SECOND_PATH", "THIRD_PATH"])

expect(message).to eq(nil)
expect(message_or_object).to eq(aws_response_object)
expect(success).to eq(true)
end

Expand Down

0 comments on commit 56714e2

Please sign in to comment.