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

Aws::DynamoDB::Client#stub_data does not honor simple_attributes #863

Closed
ajvondrak opened this issue Jul 5, 2015 · 3 comments
Closed

Aws::DynamoDB::Client#stub_data does not honor simple_attributes #863

ajvondrak opened this issue Jul 5, 2015 · 3 comments

Comments

@ajvondrak
Copy link

[1] pry(main)> require 'aws-sdk'
=> true

[2] pry(main)> Aws::VERSION
=> "2.1.2"

[3] pry(main)> client = Aws::DynamoDB::Client.new(region: 'wherever')
=> #<Aws::DynamoDB::Client>

[4] pry(main)> client.config.simple_attributes
=> true

[5] pry(main)> client.stub_data(:get_item, item: { 'id' => 'some string' })
ArgumentError: expected params[:item]["id"] to be a hash
from /Users/alexv/.rvm/gems/ruby-2.1.3/gems/aws-sdk-core-2.1.2/lib/aws-sdk-core/param_validator.rb:26:in `validate!'

[6] pry(main)> client.stub_data(:get_item, item: { 'id' => { s: 'some string' } })
=> #<struct Aws::DynamoDB::Types::GetItemOutput
 item=
  {"id"=>
    #<struct Aws::DynamoDB::Types::AttributeValue
     s="some string",
     n=nil,
     b=nil,
     ss=nil,
     ns=nil,
     bs=nil,
     m=nil,
     l=nil,
     null=nil,
     bool=nil>},
 consumed_capacity=
  #<struct Aws::DynamoDB::Types::ConsumedCapacity
   table_name="TableName",
   capacity_units=0.0,
   table=#<struct Aws::DynamoDB::Types::Capacity capacity_units=0.0>,
   local_secondary_indexes={},
   global_secondary_indexes={}>>

[7] pry(main)> _.item['id']
=> #<struct Aws::DynamoDB::Types::AttributeValue s="some string", n=nil, b=nil, ss=nil, ns=nil, bs=nil, m=nil, l=nil, null=nil, bool=nil>

Would it be possible for stub_data to translate the Ruby literals back/forth into the Aws::DynamoDB::Types structs?

In normal use, I'd expect client.get_item(...).item to be a hash with Ruby literals like { 'id' => 'some string' } by virtue of client.config.simple_attributes. So for my specs, I'd like to generate stub data of the same type that my actual code is expecting to process. Is there another way to do this that I can't figure out, or should Aws::DynamoDB::Client#stub_data be altered?

@trevorrowe
Copy link
Member

This is reasonable, and simply an oversight.

@trevorrowe
Copy link
Member

This should go out with the next release, sometime this week.

@ajvondrak
Copy link
Author

Excellent! Thank you for the speedy response.

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

3 participants