test/unit/peddler/test_client.rb in peddler-0.9.2 vs test/unit/peddler/test_client.rb in peddler-0.10.0

- old
+ new

@@ -62,18 +62,10 @@ def test_configures_when_initialising client = @klass.new(aws_access_key_id: '123') assert_equal '123', client.aws_access_key_id end - def test_guards_against_bad_marketplace_id - assert_raises(Peddler::Client::BadMarketplaceId) do - client = Peddler::Client.new - client.marketplace_id = '123' - client.get - end - end - def test_sets_content_type_header_for_latin_flat_file_body @client.body = 'foo' content_type = @client.headers.fetch('Content-Type') assert_equal 'text/tab-separated-values; charset=ISO-8859-1', content_type @@ -130,7 +122,23 @@ @client.defaults.update(instrumentor: instrumentor) @client.run headers = instrumentor.events['excon.request'][:headers] assert headers.has_key?('User-Agent') + end + + def test_error_callback + Excon.stub({}, { status: 503 }) + + assert_raises(Excon::Errors::ServiceUnavailable) do + @client.run + end + + @client.on_error do |_, res| + assert_equal 503, res.status + end + + @client.run + + Excon.stubs.clear end end