From 4df99f482603f30e2021ee7fc9e4377e87ef3303 Mon Sep 17 00:00:00 2001 From: Esteban Pastorino Date: Wed, 11 Jul 2018 13:26:54 -0700 Subject: [PATCH] Add unit test for callbacks --- spec/ddtrace/workers_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/ddtrace/workers_spec.rb diff --git a/spec/ddtrace/workers_spec.rb b/spec/ddtrace/workers_spec.rb new file mode 100644 index 0000000000..2def6ff2c2 --- /dev/null +++ b/spec/ddtrace/workers_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +RSpec.describe Datadog::Workers::AsyncTransport do + describe 'callbacks' do + describe 'when raising errors' do + it 'does not re-raise' do + buf = StringIO.new + Datadog::Tracer.log = Datadog::Logger.new(buf) + task = proc { raise StandardError } + worker = Datadog::Workers::AsyncTransport.new(nil, 100, task, task, 0.5) + + worker.enqueue_trace(get_test_traces(1)) + worker.enqueue_service(get_test_services) + + expect { worker.callback_traces }.to_not raise_error + expect { worker.callback_services }.to_not raise_error + + lines = buf.string.lines + expect(lines.length).to eq 2 + end + end + end +end