lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/sqs/send_message.rb in brightbox-cli-0.14.1 vs lib/brightbox-cli/vendor/fog/lib/fog/aws/requests/sqs/send_message.rb in brightbox-cli-0.15.0

- old
+ new

@@ -23,9 +23,47 @@ :parser => Fog::Parsers::AWS::SQS::SendMessage.new }) end end - + + class Mock + + def send_message(queue_url, message) + Excon::Response.new.tap do |response| + if (queue = data[:queues][queue_url]) + response.status = 200 + + now = Time.now + message_id = Fog::AWS::Mock.sqs_message_id + md5 = Digest::MD5.hexdigest(message) + + queue[:messages][message_id] = { + 'MessageId' => message_id, + 'Body' => message, + 'MD5OfBody' => md5, + 'Attributes' => { + 'SenderId' => Fog::AWS::Mock.sqs_message_id, + 'SentTimestamp' => now + } + } + + queue['Attributes']['LastModifiedTimestamp'] = now + + response.body = { + 'ResponseMetadata' => { + 'RequestId' => Fog::AWS::Mock.request_id + }, + 'MessageId' => message_id, + 'MD5OfMessageBody' => md5 + } + else + response.status = 404 + raise(Excon::Errors.status_error({:expects => 200}, response)) + end + end + end + + end end end end