|
5 | 5 | require 'fiddle'
|
6 | 6 |
|
7 | 7 | RSpec.describe Datadog::Core::Crashtracking::Component, skip: !CrashtrackingHelpers.supported? do
|
| 8 | + let(:logger) { Logger.new($stdout) } |
| 9 | + |
8 | 10 | describe '.build' do
|
9 | 11 | let(:settings) { Datadog::Core::Configuration::Settings.new }
|
10 | 12 | let(:agent_settings) { double('agent_settings') }
|
11 |
| - let(:logger) { Logger.new($stdout) } |
12 | 13 | let(:tags) { { 'tag1' => 'value1' } }
|
13 | 14 | let(:agent_base_url) { 'agent_base_url' }
|
14 | 15 | let(:ld_library_path) { 'ld_library_path' }
|
|
100 | 101 | describe '#start' do
|
101 | 102 | context 'when _native_start_or_update_on_fork raises an exception' do
|
102 | 103 | it 'logs the exception' do
|
103 |
| - logger = Logger.new($stdout) |
104 | 104 | crashtracker = build_crashtracker(logger: logger)
|
105 | 105 |
|
106 | 106 | expect(described_class).to receive(:_native_start_or_update_on_fork) { raise 'Test failure' }
|
|
114 | 114 | describe '#stop' do
|
115 | 115 | context 'when _native_stop_crashtracker raises an exception' do
|
116 | 116 | it 'logs the exception' do
|
117 |
| - logger = Logger.new($stdout) |
118 | 117 | crashtracker = build_crashtracker(logger: logger)
|
119 | 118 |
|
120 | 119 | expect(described_class).to receive(:_native_stop) { raise 'Test failure' }
|
|
126 | 125 | end
|
127 | 126 |
|
128 | 127 | describe '#update_on_fork' do
|
| 128 | + before { allow(logger).to receive(:debug) } |
| 129 | + |
129 | 130 | context 'when _native_stop_crashtracker raises an exception' do
|
130 | 131 | it 'logs the exception' do
|
131 |
| - logger = Logger.new($stdout) |
132 | 132 | crashtracker = build_crashtracker(logger: logger)
|
133 | 133 |
|
134 | 134 | expect(described_class).to receive(:_native_start_or_update_on_fork) { raise 'Test failure' }
|
|
138 | 138 | end
|
139 | 139 | end
|
140 | 140 |
|
141 |
| - it 'update_on_fork the crash tracker' do |
| 141 | + it 'updates the crash tracker' do |
142 | 142 | expect(described_class).to receive(:_native_start_or_update_on_fork).with(
|
143 | 143 | hash_including(action: :update_on_fork)
|
144 | 144 | )
|
145 | 145 |
|
146 |
| - crashtracker = build_crashtracker |
| 146 | + crashtracker = build_crashtracker(logger: logger) |
| 147 | + |
| 148 | + crashtracker.update_on_fork |
| 149 | + end |
| 150 | + |
| 151 | + it 'refreshes the latest settings' do |
| 152 | + allow(Datadog).to receive(:configuration).and_return(:latest_settings) |
| 153 | + allow(Datadog::Core::Crashtracking::TagBuilder).to receive(:call).with(:latest_settings).and_return([:latest_tags]) |
| 154 | + |
| 155 | + expect(described_class).to receive(:_native_start_or_update_on_fork).with( |
| 156 | + hash_including(tags_as_array: [:latest_tags]) |
| 157 | + ) |
| 158 | + |
| 159 | + crashtracker = build_crashtracker(logger: logger) |
147 | 160 |
|
148 | 161 | crashtracker.update_on_fork
|
149 | 162 | end
|
|
0 commit comments