mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
0306d3808a
commit
d7bfd25dab
2 changed files with 20 additions and 4 deletions
|
@ -111,10 +111,10 @@ class LogStash::Plugin
|
|||
|
||||
public
|
||||
def inspect
|
||||
if !@config.nil?
|
||||
description = @config \
|
||||
.select { |k,v| !v.nil? && (v.respond_to?(:empty?) && !v.empty?) } \
|
||||
.collect { |k,v| "#{k}=>#{v.inspect}" }
|
||||
if !@params.nil?
|
||||
description = @params
|
||||
.reject { |k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) }
|
||||
.collect { |k, v| "#{k}=>#{v.inspect}" }
|
||||
return "<#{self.class.name} #{description.join(", ")}>"
|
||||
else
|
||||
return "<#{self.class.name} --->"
|
||||
|
|
|
@ -29,6 +29,22 @@ describe LogStash::Plugin do
|
|||
expect(LogStash::Plugin.lookup("filter", "lady_gaga")).to eq(LogStash::Filters::LadyGaga)
|
||||
end
|
||||
|
||||
describe "#inspect" do
|
||||
class LogStash::Filters::MyTestFilter < LogStash::Filters::Base
|
||||
config_name "param1"
|
||||
config :num, :validate => :number, :default => 20
|
||||
config :str, :validate => :string, :default => "test"
|
||||
end
|
||||
subject { LogStash::Filters::MyTestFilter.new("num" => 1, "str" => "hello") }
|
||||
|
||||
it "should print the class of the filter" do
|
||||
expect(subject.inspect).to match(/^<LogStash::Filters::MyTestFilter/)
|
||||
end
|
||||
it "should list config options and values" do
|
||||
expect(subject.inspect).to match(/num=>1, str=>"hello"/)
|
||||
end
|
||||
end
|
||||
|
||||
context "when validating the plugin version" do
|
||||
let(:plugin_name) { 'logstash-filter-stromae' }
|
||||
subject do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue