From 00f6d1e91f2ca997619431eef2d66274b9b02e38 Mon Sep 17 00:00:00 2001 From: Juli Tera Date: Thu, 2 May 2024 14:00:33 -0700 Subject: [PATCH] Add tests --- .../spec/aws/query/ec2_param_builder_spec.rb | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/gems/aws-sdk-core/spec/aws/query/ec2_param_builder_spec.rb b/gems/aws-sdk-core/spec/aws/query/ec2_param_builder_spec.rb index 00638a0ba15..e24b73b1076 100644 --- a/gems/aws-sdk-core/spec/aws/query/ec2_param_builder_spec.rb +++ b/gems/aws-sdk-core/spec/aws/query/ec2_param_builder_spec.rb @@ -5,19 +5,19 @@ 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 @@ -25,13 +25,32 @@ def query(params = {}) 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