-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample rpcv2 cbor model and error handler spec
- Loading branch information
Showing
5 changed files
with
3,778 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
gems/aws-sdk-core/spec/aws/rpc_v2/error_handler_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../spec_helper' | ||
|
||
module Aws | ||
module RpcV2 | ||
describe ErrorHandler do | ||
let(:client) do | ||
ApiHelper.sample_rpcv2_cbor::Client.new(stub_responses: true) | ||
end | ||
|
||
let(:error_resp) do | ||
Cbor.encode( | ||
{ | ||
"__type": 'ServiceUnavailableException', | ||
"message": 'foo', | ||
"foo": 'bar' | ||
} | ||
) | ||
end | ||
|
||
let(:invalid_error_resp) do | ||
Cbor.encode( | ||
{ | ||
"__type": 'ServiceUnavailableException:', | ||
"message": 'foo', | ||
"foo": 'bar' | ||
} | ||
) | ||
end | ||
|
||
let(:un_modeled_error_resp) do | ||
Cbor.encode( | ||
{ | ||
"__type": 'UnModeledException', | ||
"message": 'foo' | ||
} | ||
) | ||
end | ||
|
||
let(:empty_struct_error_resp) do | ||
Cbor.encode( | ||
{ | ||
"__type": 'EmptyStructError', | ||
"message": 'foo' | ||
} | ||
) | ||
end | ||
|
||
it 'extracts error data' do | ||
client.stub_responses( | ||
:describe_log_groups, | ||
{ | ||
status_code: 400, | ||
headers: { | ||
'smithy-protocol' => 'rpc-v2-cbor' | ||
}, | ||
body: error_resp | ||
} | ||
) | ||
|
||
expect { client.describe_log_groups } | ||
.to raise_error do |e| | ||
expect(e.code).to eq('ServiceUnavailableException') | ||
expect(e.message).to eq('foo') | ||
expect(e.foo).to eq('bar') | ||
end | ||
end | ||
|
||
it 'ignore invalid characters when matching' do | ||
client.stub_responses( | ||
:describe_log_groups, | ||
{ | ||
status_code: 400, | ||
headers: { | ||
'smithy-protocol' => 'rpc-v2-cbor' | ||
}, | ||
body: invalid_error_resp | ||
} | ||
) | ||
|
||
expect { client.describe_log_groups } | ||
.to raise_error do |e| | ||
expect(e.code).to eq('ServiceUnavailableException') | ||
expect(e.message).to eq('foo') | ||
expect(e.foo).to eq('bar') | ||
end | ||
end | ||
|
||
it 'extracts code and message for unmodeled errors' do | ||
client.stub_responses( | ||
:describe_log_groups, | ||
{ | ||
status_code: 400, | ||
headers: { | ||
'smithy-protocol' => 'rpc-v2-cbor' | ||
}, | ||
body: un_modeled_error_resp | ||
} | ||
) | ||
|
||
expect { client.describe_log_groups } | ||
.to raise_error do |e| | ||
expect(e.code).to eq('UnModeledException') | ||
expect(e.message).to eq('foo') | ||
end | ||
end | ||
|
||
it 'extracts code and message for modeled empty struct errors' do | ||
client.stub_responses( | ||
:describe_log_groups, | ||
{ | ||
status_code: 400, | ||
headers: { | ||
'smithy-protocol' => 'rpc-v2-cbor' | ||
}, | ||
body: empty_struct_error_resp | ||
} | ||
) | ||
|
||
expect { client.describe_log_groups } | ||
.to raise_error do |e| | ||
expect(e.code).to eq('EmptyStructError') | ||
expect(e.message).to eq('foo') | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.