Skip to content

Commit 3595ff6

Browse files
committed
Test more specific code paths
1 parent e8afdf4 commit 3595ff6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spec/unit/outputs/elasticsearch_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,8 +1513,6 @@
15131513

15141514
let(:event_action_tuples) { subject.map_events(events) }
15151515

1516-
let(:logger) { subject.logger }
1517-
15181516
let(:bulk_response) do
15191517
{
15201518
"took"=>1, "ingest_took"=>11, "errors"=>true, "items"=>
@@ -1532,9 +1530,7 @@
15321530

15331531
context 'DLQ is enabled' do
15341532

1535-
before(:each) do
1536-
allow(subject).to receive(:dlq_enabled?).and_return(true)
1537-
end
1533+
let(:options) { super().merge("dlq_custom_codes" => [403]) }
15381534

15391535
it 'does not write the event to the DLQ' do
15401536
expect(dlq_writer).not_to receive(:write)
@@ -1548,16 +1544,16 @@
15481544
allow(subject).to receive(:dlq_enabled?).and_return(false)
15491545
end
15501546

1551-
it 'does not write the event to the DLQ' do
1552-
expect(dlq_writer).not_to receive(:write)
1553-
subject.send(:submit, event_action_tuples)
1547+
it 'does not retry indexing the event' do
1548+
expect(subject).to receive(:submit).with(event_action_tuples).once.and_call_original
1549+
subject.send(:retrying_submit, event_action_tuples)
15541550
end
15551551
end
15561552

15571553
context 'the error type is not in `silence_errors_in_log`' do
15581554

15591555
it 'logs the error' do
1560-
expect(logger).to receive(:warn).with(a_string_including("Failed action"), anything).and_call_original
1556+
expect(subject.logger).to receive(:warn).with(a_string_including("Failed action"), anything)
15611557
subject.send(:submit, event_action_tuples)
15621558
end
15631559
end
@@ -1566,8 +1562,12 @@
15661562

15671563
let(:options) { super().merge('silence_errors_in_log' => [error_type]) }
15681564

1565+
before(:each) do
1566+
# ensure that neither warn nor info is called on the logger by using a test double
1567+
subject.instance_variable_set("@logger", double('logger'))
1568+
end
1569+
15691570
it 'does not log the error' do
1570-
expect(logger).not_to receive(:warn)
15711571
subject.send(:submit, event_action_tuples)
15721572
end
15731573
end

0 commit comments

Comments
 (0)