mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Add specs for environment filter
This commit is contained in:
parent
268aa39cee
commit
5db1431208
1 changed files with 43 additions and 0 deletions
43
spec/filters/environment.rb
Normal file
43
spec/filters/environment.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
require "test_utils"
|
||||
require "logstash/filters/environment"
|
||||
|
||||
describe LogStash::Filters::Environment do
|
||||
extend LogStash::RSpec
|
||||
|
||||
describe "add a field from the environment" do
|
||||
# The logstash config goes here.
|
||||
# At this time, only filters are supported.
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
environment {
|
||||
add_field_from_env => [ "newfield", "MY_ENV_VAR" ]
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
ENV["MY_ENV_VAR"] = "hello world"
|
||||
|
||||
sample "example" do
|
||||
insist { subject["newfield"] } == "hello world"
|
||||
end
|
||||
end
|
||||
|
||||
describe "does nothing on non-matching events" do
|
||||
# The logstash config goes here.
|
||||
# At this time, only filters are supported.
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
environment {
|
||||
type => "foo"
|
||||
add_field_from_env => [ "newfield", "MY_ENV_VAR" ]
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
ENV["MY_ENV_VAR"] = "hello world"
|
||||
|
||||
sample({ "@type" => "bar", "@message" => "fizz", "@fields" => { } }) do
|
||||
insist { subject["newfield"] }.nil?
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue