Sha256: 991e5f6e3f70939b5d1ae5e053b4b38d9ce37d7575285e9a6104c10ed2893744

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require "spec_helper"
require "logstash/filters/environment"

describe LogStash::Filters::Environment do
  

  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-filter-environment-0.1.0 spec/filters/environment_spec.rb