Skip to content

Commit

Permalink
spec test for filter/split
Browse files Browse the repository at this point in the history
  • Loading branch information
wiibaa committed May 14, 2013
1 parent be36b7f commit ee9bd0c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions spec/filters/split.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
require "test_utils"
require "logstash/filters/split"

describe LogStash::Filters::Split do
extend LogStash::RSpec

describe "all defaults" do
config <<-CONFIG
filter {
split { }
}
CONFIG

sample "big\nbird\nsesame street" do
insist { subject.length } == 3
insist { subject[0]["@message"] } == "big"
insist { subject[1]["@message"] } == "bird"
insist { subject[2]["@message"] } == "sesame street"
end
end

describe "custome terminator" do
config <<-CONFIG
filter {
split {
terminator => "\t"
}
}
CONFIG

sample "big\tbird\tsesame street" do
insist { subject.length } == 3
insist { subject[0]["@message"] } == "big"
insist { subject[1]["@message"] } == "bird"
insist { subject[2]["@message"] } == "sesame street"
end
end

describe "custom field" do
config <<-CONFIG
filter {
split {
field => "custom"
}
}
CONFIG

sample ({"@fields" => { "custom" => "big\nbird\nsesame street", "do_not_touch" => "1\n2\n3"}}) do
insist { subject.length } == 3
subject.each do |s|
insist { s["do_not_touch"] } == "1\n2\n3"
end
insist { subject[0]["custom"] } == "big"
insist { subject[1]["custom"] } == "bird"
insist { subject[2]["custom"] } == "sesame street"
end
end
end

0 comments on commit ee9bd0c

Please sign in to comment.