From 00fe4467ed3a819c14b4c2fb7e39077ebe1de97a Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Wed, 5 Jun 2024 13:32:21 -0400 Subject: [PATCH] move tests --- .../datadog/core/configuration/option_spec.rb | 29 +++++++++++++++++++ .../core/configuration/options_spec.rb | 28 ------------------ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/spec/datadog/core/configuration/option_spec.rb b/spec/datadog/core/configuration/option_spec.rb index d84aa576ba9..76a3b1f2fee 100644 --- a/spec/datadog/core/configuration/option_spec.rb +++ b/spec/datadog/core/configuration/option_spec.rb @@ -839,6 +839,35 @@ end end + context 'when env is an Array' do + let(:env) { ['TEST_ENV_VAR', 'TEST_ENV_VAR2'] } + let(:setter) { proc { |value| value } } + + around do |example| + ClimateControl.modify(set_envs) { example.run } + end + + context 'and the first environmet variable is set' do + let(:set_envs) { { 'TEST_ENV_VAR' => 'val1' } } + it { is_expected.to eq('val1') } + end + + context 'and the second environmet variable is set' do + let(:set_envs) { { 'TEST_ENV_VAR2' => 'val2' } } + it { is_expected.to eq('val2') } + end + + context 'and both environmet variables are set' do + let(:set_envs) { { 'TEST_ENV_VAR' => 'val1', 'TEST_ENV_VAR2' => 'val2' } } + it { is_expected.to eq('val1') } + end + + context 'and environmet variables are not set' do + let(:set_envs) { {} } + it { is_expected.to be(default) } + end + end + context 'when deprecated_env is defined' do before do allow(Datadog.logger).to receive(:warn) # For deprecation warnings diff --git a/spec/datadog/core/configuration/options_spec.rb b/spec/datadog/core/configuration/options_spec.rb index b7cf6c62006..5b73400d0d0 100644 --- a/spec/datadog/core/configuration/options_spec.rb +++ b/spec/datadog/core/configuration/options_spec.rb @@ -234,34 +234,6 @@ context 'when the option is not defined' do it { expect { get_option }.to raise_error(described_class::InvalidOptionError) } end - - context 'when environment variables are configured' do - before { options_class.send(:option, name, meta) } - let(:meta) { { name: 'test-env', env: ['TEST_ENV_VAR', 'TEST_ENV_VAR2'], type: :string, default: 'default' } } - around do |example| - ClimateControl.modify(set_envs) { example.run } - end - - context 'and the first environmet variable is set' do - let(:set_envs) { { 'TEST_ENV_VAR' => 'val1' } } - it { is_expected.to eq('val1') } - end - - context 'and the second environmet variable is set' do - let(:set_envs) { { 'TEST_ENV_VAR2' => 'val2' } } - it { is_expected.to eq('val2') } - end - - context 'and both environmet variables are set' do - let(:set_envs) { { 'TEST_ENV_VAR' => 'val1', 'TEST_ENV_VAR2' => 'val2' } } - it { is_expected.to eq('val1') } - end - - context 'and environmet variables are not set' do - let(:set_envs) { {} } - it { is_expected.to eq('default') } - end - end end describe '#reset_option' do