Skip to content

Commit

Permalink
Fix query and xml tests (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp authored Aug 9, 2024
1 parent 767ff65 commit c8ffda0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end
gem 'json'
gem 'nokogiri', '>= 1.6.8.1'
gem 'oga'
gem 'rexml', '= 3.2.6' # Temporary Workaround (https://github.com/ruby/rexml/issues/131)
gem 'rexml'
# These protocol parsers do not have java gems
unless defined?(JRUBY_VERSION)
gem 'libxml-ruby'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,5 @@
"engines": ["nokogiri"]
}
}
},
"query": {
"input": {},
"output": {
"QueryCustomizedError": {
"description": "Under investigation",
"engines": ["ox", "nokogiri", "rexml", "libxml", "oga"]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@
]
},
"description": "Parses customized XML errors",
"errorCode": "CustomCodeError",
"errorCode": "Customized",
"errorMessage": "Hi",
"error": {
"Message": "Hi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,13 @@ def match_resp_data(test_case, http_resp, it)
expected_data =
if error_case?(test_case)
error_shape = http_resp.context.operation.errors.find do |err|
err.shape.name == test_case['errorCode']
shape =
if err.shape['error']
err.shape['error']['code']
else
err.shape.name
end
shape == test_case['errorCode']
end
raise "Unable to find #{test_case['errorCode']} in error shapes" if error_shape.nil?

Expand Down Expand Up @@ -380,6 +386,8 @@ def normalize_headers(hash)

def normalize_xml(xml)
REXML::Document.new(xml).to_s.gsub(/>\s+?</, '><').strip
rescue REXML::ParseException
xml # payload
end

def error_case?(test_case)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ def normalize(xml)
operation = api.operation(:get_bucket_policy)
resp = RestXml.new.stub_data(api, operation, params)
expect(resp.status_code).to eq(200)
expect(normalize(resp.body.string)).to eq(normalize(<<-JSON))
{
"Policy": "policy-document"
}
JSON
expect(resp.body.string).to eq('policy-document')
end

it 'can stub errors' do
Expand Down

0 comments on commit c8ffda0

Please sign in to comment.