Sha256: 3333513f29eb2027eda063ebb431f2338aac823e242089fd85abae2177aab9bd

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

# encoding: utf-8

require "logstash/devutils/rspec/spec_helper"
require "logstash/filters/unique"

describe LogStash::Filters::Unique do

  describe "unique on non array should return origin value" do
    # The logstash config goes here.
    # At this time, only filters are supported.
    config <<-CONFIG
      filter {
        unique {
          fields => ["field1"]
        }
      }
    CONFIG

    sample("field1" => "asdf") do
      insist { subject.get("field1") } == "asdf"
    end
  end

  describe "unique on array of integers" do
    # The logstash config goes here.
    # At this time, only filters are supported.
    config <<-CONFIG
      filter {
        unique {
          fields => ["field2"]
        }
      }
    CONFIG

    sample("field2" => [1,2,1,2,1,2,1,2]) do
      insist { subject.get("field2") } == [1,2]
    end
  end


  describe "unique on array of strings" do
    # The logstash config goes here.
    # At this time, only filters are supported.
    config <<-CONFIG
      filter {
        unique {
          fields => ["field3"]
        }
      }
    CONFIG

    sample("field3" => ["a", "b", "c", "c", "d"]) do
      insist { subject.get("field3") } == ["a", "b", "c", "d"]
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
logstash-filter-unique-3.0.0 spec/filters/unique_spec.rb
logstash-filter-unique-sbt-3.0.0 spec/filters/unique_spec.rb
logstash-filter-unique2-3.0.0 spec/filters/unique_spec.rb