Skip to content

Commit

Permalink
move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Jun 5, 2024
1 parent 5598751 commit 94fc388
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
29 changes: 29 additions & 0 deletions spec/datadog/core/configuration/option_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions spec/datadog/core/configuration/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 94fc388

Please sign in to comment.