Sha256: 9772e4a01876846d1f6326f626bda6838532382a98fdea2aabb01a2071b2707f

Contents?: true

Size: 1009 Bytes

Versions: 5

Compression:

Stored size: 1009 Bytes

Contents

require "logstash/devutils/rspec/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

5 entries across 5 versions & 1 rubygems

Version Path
logstash-filter-environment-0.1.5 spec/filters/environment_spec.rb
logstash-filter-environment-0.1.4 spec/filters/environment_spec.rb
logstash-filter-environment-0.1.3 spec/filters/environment_spec.rb
logstash-filter-environment-0.1.2 spec/filters/environment_spec.rb
logstash-filter-environment-0.1.1 spec/filters/environment_spec.rb