Sha256: 956826752abe6eb171fdbd8f12878eac22668dbe96a8fac7f9c45dfdb2b3dc3d
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
# encoding: utf-8 require "logstash/devutils/rspec/spec_helper" require "logstash/filters/units" describe LogStash::Filters::Units do describe "special field" do let(:config) do <<-CONFIG filter { units { fields => ["[a1][a2]", "b1", "c1", "d2"] input_unit => "byte" output_units => ["kibibyte", "mebibyte"] root_field => "special" rename_labels => { "kibibyte" => "kb" "mebibyte" => "mb" } } } CONFIG end event = { "a1" => { "a2" => 1024 }, "b1" => 1024, "c1" => 1024, "d1" => { "d2" => 1024 } } sample(event) do insist { subject["special"]["a1"]["a2"]["kb"] } == 1 insist { subject["special"]["a1"]["a2"]["kb"] } == 1 insist { subject["special"]["b1"]["kb"] } == 1 insist { subject["special"]["c1"]["kb"] } == 1 insist { subject["special"]["d1"]["d2"]["kb"] } == 1 end end describe "in place" do let(:config) do <<-CONFIG filter { units { fields => ["[a1][a2]", "b1", "c1", "d2"] input_unit => "byte" output_units => ["kibibyte", "mebibyte"] rename_labels => { "kibibyte" => "kb" "mebibyte" => "mb" } } } CONFIG end event = { "a1" => { "a2" => 1024**2 }, "b1" => 1024**2, "c1" => 1024**2, "d1" => { "d2" => 1024**2 } } sample(event) do insist { subject["a1"]["a2"]["mb"] } == 1 insist { subject["b1"]["mb"] } == 1 insist { subject["c1"]["mb"] } == 1 insist { subject["d1"]["d2"]["mb"] } == 1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logstash-filter-units-0.1.2 | spec/filters/units_spec.rb |
logstash-filter-units-0.1.1 | spec/filters/units_spec.rb |