Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: delegating from deprecated setting #13481

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion logstash-core/lib/logstash/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ def value

def validate_value
# bypass deprecation warning
validate(wrapped.value) if set?
wrapped.validate_value if set?
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,45 @@
end

context "when only the deprecated alias is set" do

let(:value) { "crusty_value" }

before(:each) do
settings.set(deprecated_setting_name, "crusty_value")
settings.set(deprecated_setting_name, value)
end

it 'resolves to the value provided for the deprecated alias' do
expect(settings.get(canonical_setting_name)).to eq("crusty_value")
expect(settings.get(canonical_setting_name)).to eq(value)
end

it 'logs a deprecation warning' do
expect(LogStash::Settings.deprecation_logger).to have_received(:deprecated).with(a_string_including(deprecated_setting_name))
end

include_examples '#validate_value success'

it 'validates deprecated alias' do
expect { settings.get_setting(canonical_setting_name).deprecated_alias.validate_value }.to_not raise_error
end

context 'using a boolean setting' do

let(:value) { true }
let(:default_value) { false }

let(:canonical_setting) { LogStash::Setting::Boolean.new(canonical_setting_name, default_value, true) }

it 'resolves to the value provided for the deprecated alias' do
expect(settings.get(canonical_setting_name)).to eq(true)
end

include_examples '#validate_value success'

it 'validates deprecated alias' do
expect { settings.get_setting(canonical_setting_name).deprecated_alias.validate_value }.to_not raise_error
end

end
end

context "when only the canonical setting is set" do
Expand Down