merge tests

This commit is contained in:
Wiibaa 2012-10-26 07:22:59 +02:00
parent 6f74511067
commit c3c4b8dbe6

View file

@ -37,4 +37,67 @@ describe LogStash::Filters::CSV do
insist { subject["address"] } == "sesame street"
end
end
describe "parse csv with more data than defined field names" do
config <<-CONFIG
filter {
csv {
fields => ["custom1", "custom2"]
}
}
CONFIG
sample "val1,val2,val3" do
insist { subject["custom1"] } == "val1"
insist { subject["custom2"] } == "val2"
insist { subject["field3"] } == "val3"
end
end
describe "parse csv from a given field without field names" do
config <<-CONFIG
filter {
csv {
raw => "data"
}
}
CONFIG
sample({"@fields" => {"raw" => "val1,val2,val3"}}) do
insist { subject["data"]["field1"] } == "val1"
insist { subject["data"]["field2"] } == "val2"
insist { subject["data"]["field3"] } == "val3"
end
end
describe "parse csv from a given field with field names" do
config <<-CONFIG
filter {
csv {
raw => "data"
fields => ["custom1", "custom2", "custom3"]
}
}
CONFIG
sample({"@fields" => {"raw" => "val1,val2,val3"}}) do
insist { subject["data"]["custom1"] } == "val1"
insist { subject["data"]["custom2"] } == "val2"
insist { subject["data"]["custom3"] } == "val3"
end
end
describe "fail to parse any data in a multi-value field" do
config <<-CONFIG
filter {
csv {
raw => "data"
}
}
CONFIG
sample({"@fields" => {"raw" => ["val1,val2,val3", "val1,val2,val3"]}}) do
insist { subject["data"] } == nil
end
end
end