Sha256: ea5965938f90a4c0900a215e0e8d2cf2ef3b2193fa659b6176aaa3f927047c63

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

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") do
      insist { subject["newfield"] }.nil?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-lib-1.3.2 spec/filters/environment.rb