Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jterapin committed May 2, 2024
1 parent c9e5f9b commit 00f6d1e
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions gems/aws-sdk-core/spec/aws/query/ec2_param_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,52 @@
module Aws
module Query
describe EC2ParamBuilder do

let(:shapes) { ApiHelper.sample_shapes }

let(:rules) {
ApiHelper.sample_api(shapes:shapes).
operation(:example_operation).
input
}
let(:rules) do
ApiHelper
.sample_api(shapes: shapes)
.operation(:example_operation)
.input
end

def query(params = {})
param_list = ParamList.new
EC2ParamBuilder.new(param_list).apply(rules, params)
param_list.map { |param| [param.name, param.value ] }.sort
param_list.map { |param| [param.name, param.value] }.sort
end

it 'can serialize structures' do
params = Structure.new(*rules.shape.member_names).new
params.boolean = true
params.integer = 123
params.string = 'abc'
expect(query(params)).to eq([
['Boolean', 'true'],
['Integer', '123'],
['String', 'abc'],
])
expect(query(params)).to eq(
[
%w[Boolean true],
%w[Integer 123],
%w[String abc]
]
)
end

it 'can serialize non-empty lists' do
params = Structure.new(*rules.shape.member_names).new
params.number_list = [1, 2, 3]
expect(query(params)).to eq(
[
%w[NumberList.1 1],
%w[NumberList.2 2],
%w[NumberList.3 3]
]
)
end

it 'does not serialize empty lists' do
params = Structure.new(*rules.shape.member_names).new
params.number_list = []
expect(query(params)).to be_empty
end
end
end
end

0 comments on commit 00f6d1e

Please sign in to comment.