From 2a26069930481caf5d56ccbce31c2e0c9d939996 Mon Sep 17 00:00:00 2001 From: Michael Hale Date: Thu, 2 Jul 2015 18:08:27 -0400 Subject: [PATCH] Raise real errors in mocks --- lib/fog/aws/requests/kinesis/add_tags_to_stream.rb | 2 +- lib/fog/aws/requests/kinesis/delete_stream.rb | 2 +- lib/fog/aws/requests/kinesis/get_records.rb | 4 ++-- lib/fog/aws/requests/kinesis/get_shard_iterator.rb | 3 ++- lib/fog/aws/requests/kinesis/list_tags_for_stream.rb | 2 +- lib/fog/aws/requests/kinesis/merge_shards.rb | 8 +++++--- lib/fog/aws/requests/kinesis/put_record.rb | 2 +- lib/fog/aws/requests/kinesis/put_records.rb | 2 +- lib/fog/aws/requests/kinesis/remove_tags_from_stream.rb | 2 +- lib/fog/aws/requests/kinesis/split_shard.rb | 4 ++-- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/fog/aws/requests/kinesis/add_tags_to_stream.rb b/lib/fog/aws/requests/kinesis/add_tags_to_stream.rb index 1d07df252..3bd47fe20 100644 --- a/lib/fog/aws/requests/kinesis/add_tags_to_stream.rb +++ b/lib/fog/aws/requests/kinesis/add_tags_to_stream.rb @@ -32,7 +32,7 @@ module Fog tags = options.delete("Tags") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end stream["Tags"] = stream["Tags"].merge(tags) diff --git a/lib/fog/aws/requests/kinesis/delete_stream.rb b/lib/fog/aws/requests/kinesis/delete_stream.rb index 9f315eda5..9446a324c 100644 --- a/lib/fog/aws/requests/kinesis/delete_stream.rb +++ b/lib/fog/aws/requests/kinesis/delete_stream.rb @@ -29,7 +29,7 @@ module Fog stream_name = options.delete("StreamName") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end data[:kinesis_streams].delete(stream) diff --git a/lib/fog/aws/requests/kinesis/get_records.rb b/lib/fog/aws/requests/kinesis/get_records.rb index e34dbcd2e..4708518a8 100644 --- a/lib/fog/aws/requests/kinesis/get_records.rb +++ b/lib/fog/aws/requests/kinesis/get_records.rb @@ -37,11 +37,11 @@ module Fog starting_sequence_number = (shard_iterator["StartingSequenceNumber"] || 1).to_i unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end unless shard = stream["Shards"].detect{ |shard| shard["ShardId"] == shard_id } - raise 'unknown shard' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Could not find shard foo in stream #{stream_name} under account #{@account_id}.") end records = [] diff --git a/lib/fog/aws/requests/kinesis/get_shard_iterator.rb b/lib/fog/aws/requests/kinesis/get_shard_iterator.rb index f50d82845..8f92e3d3a 100644 --- a/lib/fog/aws/requests/kinesis/get_shard_iterator.rb +++ b/lib/fog/aws/requests/kinesis/get_shard_iterator.rb @@ -37,7 +37,8 @@ module Fog stream_name = options["StreamName"] unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") + end response = Excon::Response.new diff --git a/lib/fog/aws/requests/kinesis/list_tags_for_stream.rb b/lib/fog/aws/requests/kinesis/list_tags_for_stream.rb index d49cbe25d..68ab62f22 100644 --- a/lib/fog/aws/requests/kinesis/list_tags_for_stream.rb +++ b/lib/fog/aws/requests/kinesis/list_tags_for_stream.rb @@ -37,7 +37,7 @@ module Fog stream_name = options.delete("StreamName") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end response = Excon::Response.new diff --git a/lib/fog/aws/requests/kinesis/merge_shards.rb b/lib/fog/aws/requests/kinesis/merge_shards.rb index f49d62889..a8e63ff97 100644 --- a/lib/fog/aws/requests/kinesis/merge_shards.rb +++ b/lib/fog/aws/requests/kinesis/merge_shards.rb @@ -35,15 +35,17 @@ module Fog adjacent_shard_to_merge_id = options.delete("AdjacentShardToMerge") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end unless shard_to_merge = stream["Shards"].detect{ |shard| shard["ShardId"] == shard_to_merge_id } - raise 'unknown shard' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Could not find shard foo in stream #{stream_name} under account #{@account_id}.") + end unless adjacent_shard_to_merge = stream["Shards"].detect{ |shard| shard["ShardId"] == adjacent_shard_to_merge_id } - raise 'unknown shard' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Could not find shard foo in stream #{stream_name} under account #{@account_id}.") + end # Close shards (set an EndingSequenceNumber on them) diff --git a/lib/fog/aws/requests/kinesis/put_record.rb b/lib/fog/aws/requests/kinesis/put_record.rb index 26e2963fa..bb6c6ec54 100644 --- a/lib/fog/aws/requests/kinesis/put_record.rb +++ b/lib/fog/aws/requests/kinesis/put_record.rb @@ -38,7 +38,7 @@ module Fog stream_name = options.delete("StreamName") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end sequence_number = next_sequence_number diff --git a/lib/fog/aws/requests/kinesis/put_records.rb b/lib/fog/aws/requests/kinesis/put_records.rb index 3c7648550..6b81cdb5a 100644 --- a/lib/fog/aws/requests/kinesis/put_records.rb +++ b/lib/fog/aws/requests/kinesis/put_records.rb @@ -36,7 +36,7 @@ module Fog def put_records(options={}) stream_name = options.delete("StreamName") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end records = options.delete("Records") diff --git a/lib/fog/aws/requests/kinesis/remove_tags_from_stream.rb b/lib/fog/aws/requests/kinesis/remove_tags_from_stream.rb index 318cf633a..3bbfcf6b9 100644 --- a/lib/fog/aws/requests/kinesis/remove_tags_from_stream.rb +++ b/lib/fog/aws/requests/kinesis/remove_tags_from_stream.rb @@ -32,7 +32,7 @@ module Fog tags = options.delete("TagKeys") unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end stream["Tags"] = stream["Tags"].delete_if { |k,_| tags.include?(k) } diff --git a/lib/fog/aws/requests/kinesis/split_shard.rb b/lib/fog/aws/requests/kinesis/split_shard.rb index bc58e79d5..5851863bf 100644 --- a/lib/fog/aws/requests/kinesis/split_shard.rb +++ b/lib/fog/aws/requests/kinesis/split_shard.rb @@ -35,11 +35,11 @@ module Fog stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } unless stream = data[:kinesis_streams].detect{ |s| s["StreamName"] == stream_name } - raise 'unknown stream' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Stream #{stream_name} under account #{@account_id} not found.") end unless shard = stream["Shards"].detect{ |shard| shard["ShardId"] == shard_id } - raise 'unknown shard' + raise Fog::AWS::Kinesis::ResourceNotFound.new("Could not find shard foo in stream #{stream_name} under account #{@account_id}.") end # Close original shard (set an EndingSequenceNumber on it)