|
45 | 45 | let(:result) { engine.fetch_value(flag_key: 'test', expected_type: :string) } |
46 | 46 |
|
47 | 47 | 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 | + |
49 | 53 | expect(result.error_code).to eq('PROVIDER_NOT_READY') |
50 | 54 | expect(result.error_message).to eq('Waiting for universal flag configuration') |
51 | 55 | expect(result.reason).to eq('INITIALIZING') |
|
72 | 76 | ) |
73 | 77 | end |
74 | 78 |
|
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 | + |
76 | 82 | expect(result.error_code).to eq('PROVIDER_FATAL') |
77 | 83 | expect(result.error_message).to eq('Ooops') |
78 | 84 | expect(result.reason).to eq('ERROR') |
|
91 | 97 |
|
92 | 98 | let(:error) { RuntimeError.new("Crash") } |
93 | 99 |
|
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 | + |
95 | 103 | expect(result.error_code).to eq('PROVIDER_FATAL') |
96 | 104 | expect(result.error_message).to eq('Crash') |
97 | 105 | expect(result.reason).to eq('ERROR') |
|
106 | 114 |
|
107 | 115 | let(:result) { engine.fetch_value(flag_key: 'test', expected_type: :whatever) } |
108 | 116 |
|
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 | + |
110 | 120 | expect(result.error_code).to eq('UNKNOWN_TYPE') |
111 | 121 | expect(result.error_message).to start_with('unknown type :whatever, allowed types') |
112 | 122 | expect(result.reason).to eq('ERROR') |
|
119 | 129 | engine.reconfigure! |
120 | 130 | end |
121 | 131 |
|
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) |
123 | 138 |
|
124 | | - it 'returns resolved value' do |
125 | 139 | expect(result.value).to eq('hello') |
126 | 140 | end |
127 | 141 | end |
|
158 | 172 | it 'persists previouly configured evaluator' do |
159 | 173 | allow(logger).to receive(:error) |
160 | 174 | allow(telemetry).to receive(:report) |
| 175 | + allow(reporter).to receive(:report) |
161 | 176 |
|
162 | 177 | engine.configuration = '{}' |
163 | 178 | expect { engine.reconfigure! }.not_to change { |
|
0 commit comments