Skip to content

Commit 9e7efb0

Browse files
committed
Fix tests after rebase
1 parent d216be1 commit 9e7efb0

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

lib/datadog/open_feature/exposures/deduplicator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def duplicate?(event)
2121
stored = @cache[cache_key]
2222
return true if stored == cache_digest
2323

24-
@mutex.synchronize { @cache.store(cache_key, cache_digest) }
24+
@mutex.synchronize { @cache[cache_key] = cache_digest }
2525
false
2626
end
2727

spec/datadog/open_feature/evaluation_engine_spec.rb

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545
let(:result) { engine.fetch_value(flag_key: 'test', expected_type: :string) }
4646

4747
context 'when binding evaluator is not ready' do
48-
it 'returns evaluation error' do
48+
it 'returns evaluation error and reports exposure' do
49+
expect(reporter).to receive(:report).with(
50+
kind_of(Datadog::OpenFeature::Binding::ResolutionDetails), flag_key: 'test', context: nil
51+
)
52+
4953
expect(result.error_code).to eq('PROVIDER_NOT_READY')
5054
expect(result.error_message).to eq('Waiting for universal flag configuration')
5155
expect(result.reason).to eq('INITIALIZING')
@@ -72,7 +76,9 @@
7276
)
7377
end
7478

75-
it 'returns evaluation error' do
79+
it 'returns evaluation error and reports exposure' do
80+
expect(reporter).to receive(:report).with(error, flag_key: 'test', context: nil)
81+
7682
expect(result.error_code).to eq('PROVIDER_FATAL')
7783
expect(result.error_message).to eq('Ooops')
7884
expect(result.reason).to eq('ERROR')
@@ -91,7 +97,9 @@
9197

9298
let(:error) { RuntimeError.new("Crash") }
9399

94-
it 'returns evaluation error' do
100+
it 'returns evaluation error and does not report exposure' do
101+
expect(reporter).not_to receive(:report)
102+
95103
expect(result.error_code).to eq('PROVIDER_FATAL')
96104
expect(result.error_message).to eq('Crash')
97105
expect(result.reason).to eq('ERROR')
@@ -106,7 +114,9 @@
106114

107115
let(:result) { engine.fetch_value(flag_key: 'test', expected_type: :whatever) }
108116

109-
it 'returns evaluation error' do
117+
it 'returns evaluation error and does not report exposure' do
118+
expect(reporter).not_to receive(:report)
119+
110120
expect(result.error_code).to eq('UNKNOWN_TYPE')
111121
expect(result.error_message).to start_with('unknown type :whatever, allowed types')
112122
expect(result.reason).to eq('ERROR')
@@ -119,9 +129,13 @@
119129
engine.reconfigure!
120130
end
121131

122-
let(:result) { engine.fetch_value(flag_key: 'test', expected_type: :string) }
132+
let(:evaluation_context) { instance_double('OpenFeature::SDK::EvaluationContext') }
133+
let(:result) { engine.fetch_value(flag_key: 'test', expected_type: :string, evaluation_context: evaluation_context) }
134+
135+
it 'returns resolved value and reports exposure' do
136+
expect(reporter).to receive(:report)
137+
.with(kind_of(Datadog::OpenFeature::Binding::ResolutionDetails), flag_key: 'test', context: evaluation_context)
123138

124-
it 'returns resolved value' do
125139
expect(result.value).to eq('hello')
126140
end
127141
end
@@ -158,6 +172,7 @@
158172
it 'persists previouly configured evaluator' do
159173
allow(logger).to receive(:error)
160174
allow(telemetry).to receive(:report)
175+
allow(reporter).to receive(:report)
161176

162177
engine.configuration = '{}'
163178
expect { engine.reconfigure! }.not_to change {

spec/datadog/open_feature/provider_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
RSpec.describe Datadog::OpenFeature::Provider do
88
before do
99
allow(telemetry).to receive(:report)
10+
allow(reporter).to receive(:report)
1011
allow(Datadog::OpenFeature).to receive(:engine).and_return(engine)
1112
end
1213

0 commit comments

Comments
 (0)