Skip to content

Commit

Permalink
Minor, just DRY-ed up some test code
Browse files Browse the repository at this point in the history
  • Loading branch information
andsel committed Jan 24, 2020
1 parent 3388550 commit 6af7a6c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
describe LogStash::Api::Commands::DefaultMetadata do
include_context "api setup"

def registerIfNot(setting)
LogStash::SETTINGS.register(setting) unless LogStash::SETTINGS.registered?(setting.name)
end

let(:report_method) { :all }
subject(:report) do
factory = ::LogStash::Api::CommandFactory.new(LogStash::Api::Service.new(@agent))
Expand All @@ -13,10 +17,10 @@
let(:report_class) { described_class }

before :all do
LogStash::SETTINGS.register(LogStash::Setting::Boolean.new("xpack.monitoring.enabled", false)) unless LogStash::SETTINGS.registered?("xpack.monitoring.enabled")
LogStash::SETTINGS.register(LogStash::Setting::ArrayCoercible.new("xpack.monitoring.elasticsearch.hosts", String, [ "http://localhost:9200" ] )) unless LogStash::SETTINGS.registered?("xpack.monitoring.elasticsearch.hosts")
LogStash::SETTINGS.register(LogStash::Setting::NullableString.new("xpack.monitoring.elasticsearch.username", "logstash_TEST system")) unless LogStash::SETTINGS.registered?("xpack.monitoring.elasticsearch.username")
LogStash::SETTINGS.register(LogStash::Setting::NullableString.new("monitoring.cluster_uuid")) unless LogStash::SETTINGS.registered?("monitoring.cluster_uuid")
registerIfNot(LogStash::Setting::Boolean.new("xpack.monitoring.enabled", false))
registerIfNot(LogStash::Setting::ArrayCoercible.new("xpack.monitoring.elasticsearch.hosts", String, [ "http://localhost:9200" ] ))
registerIfNot(LogStash::Setting::NullableString.new("xpack.monitoring.elasticsearch.username", "logstash_TEST system"))
registerIfNot(LogStash::Setting::NullableString.new("xpack.monitoring.elasticsearch.username", "logstash_TEST system"))
end

after :each do
Expand Down

0 comments on commit 6af7a6c

Please sign in to comment.