Skip to content

Commit

Permalink
Fix cbor engine spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Oct 18, 2024
1 parent f1006df commit f2aa7f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
require_relative '../../spec_helper'
require 'aws-sdk-core/cbor/cbor_engine'

module Aws
module Cbor
module RpcV2
describe CborEngine do
context 'decode success tests' do
file = File.expand_path('decode-success-tests.json', __dir__)
file = File.expand_path('rpcv2-decode-success-tests.json', __dir__)
test_cases = JSON.load_file(file)

def expected_value(expect)
Expand All @@ -24,7 +23,7 @@ def expected_value(expect)
end
when 'tag'
value = expected_value(expect['tag']['value'])
Tagged.new(expect['tag']['id'], value)
Cbor::Tagged.new(expect['tag']['id'], value)
when 'bool' then expect['bool']
when 'null' then nil
when 'undefined' then :undefined
Expand Down Expand Up @@ -54,23 +53,23 @@ def assert(actual, expected)
test_cases.each do |test_case|
it "passes #{test_case['description']}" do
input = [test_case['input']].pack('H*')
actual = Aws::Cbor::CborEngine.decode(input)
actual = Aws::RpcV2::CborEngine.decode(input)
expected = expected_value(test_case['expect'])
assert(actual, expected)
end
end
end

context 'decode error tests' do
file = File.expand_path('decode-error-tests.json', __dir__)
file = File.expand_path('rpcv2-decode-error-tests.json', __dir__)
test_cases = JSON.load_file(file)

test_cases.each do |test_case|
it "passes #{test_case['description']}" do
input = [test_case['input']].pack('H*')

expect { Aws::Cbor::CborEngine.decode(input) }
.to raise_error(Error)
expect { Aws::RpcV2::CborEngine.decode(input) }
.to raise_error(Cbor::Error)
end
end
end
Expand Down

0 comments on commit f2aa7f5

Please sign in to comment.