Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't stub responses for SQS get_queue_attributes #1099

Closed
manabusakai opened this issue Feb 23, 2016 · 4 comments
Closed

Can't stub responses for SQS get_queue_attributes #1099

manabusakai opened this issue Feb 23, 2016 · 4 comments

Comments

@manabusakai
Copy link

Hi,

I'm having an issue with stubbing responses for the SQS get_queue_attributes request.

This is the sample code.

client = Aws::SQS::Client.new(region: 'ap-northeast-1', stub_responses: true)

client.stub_responses(:get_queue_attributes, attributes: {
  'QueueArn'                              => 'arn:aws:sqs:ap-northeast-1:123456789123:test',
  'ApproximateNumberOfMessages'           => '0',
  'ApproximateNumberOfMessagesNotVisible' => '0',
  'ApproximateNumberOfMessagesDelayed'    => '0',
  'CreatedTimestamp'                      => '1456210774',
  'LastModifiedTimestamp'                 => '1456210774',
  'VisibilityTimeout'                     => '30',
  'MaximumMessageSize'                    => '262144',
  'MessageRetentionPeriod'                => '345600',
  'DelaySeconds'                          => '10',
  'ReceiveMessageWaitTimeSeconds'         => '10'
})

p client.get_queue_attributes({
  queue_url: 'https://sqs.ap-northeast-1.amazonaws.com/012345678901/test',
  attribute_names: ['All'],
}).attributes

However, the result will be empty.

{""=>""}

The other operation is no problem.

client.stub_responses(:list_queues, queue_urls: [
  'https://sqs.ap-northeast-1.amazonaws.com/123456789123/test',
])

p client.list_queues.queue_urls
# result -> ["https://sqs.ap-northeast-1.amazonaws.com/123456789123/test"]
client.stub_responses(:get_queue_url, queue_url: 'https://sqs.ap-northeast-1.amazonaws.com/123456789123/test')

p client.get_queue_url({
  queue_name: 'test',
  queue_owner_aws_account_id: '123456789123',
}).queue_url
# result -> "https://sqs.ap-northeast-1.amazonaws.com/123456789123/test"

Is my usage is incorrect?

@trevorrowe
Copy link
Member

@manabusakai Your usage is correct. This bug was fixed in the previous release. You can see a related issue here: #1097

If you update to v2.2.18, then this should be fixed.

@manabusakai
Copy link
Author

@trevorrowe Thanks for the quick reply!

Update to v2.2.18, I tried it. I found a another issue.

Good when attribute is one. 😄

client.stub_responses(:get_queue_attributes, attributes: {
  'QueueArn' => 'arn:aws:sqs:ap-northeast-1:123456789123:test',
})

p client.get_queue_attributes({
  queue_url: 'https://sqs.ap-northeast-1.amazonaws.com/012345678901/test',
  attribute_names: ['All'],
}).attributes
# result -> {"QueueArn"=>"arn:aws:sqs:ap-northeast-1:123456789123:test"}

Not good when attribute is two or more. 😢

client.stub_responses(:get_queue_attributes, attributes: {
  'QueueArn'                    => 'arn:aws:sqs:ap-northeast-1:123456789123:test',
  'ApproximateNumberOfMessages' => '0',
})

p client.get_queue_attributes({
  queue_url: 'https://sqs.ap-northeast-1.amazonaws.com/012345678901/test',
  attribute_names: ['All'],
}).attributes
# result -> {"QueueArnApproximateNumberOfMessages"=>"arn:aws:sqs:ap-northeast-1:123456789123:test0"}

@trevorrowe
Copy link
Member

Good catch. I expanded the test to have multiple values and fixed the bug. This should go out with todays release.

@manabusakai
Copy link
Author

@trevorrowe Thank you! 👍

trevorrowe added a commit that referenced this issue Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants