Sha256: e483580b452cc26af5f06aeeadc1026c7813791b119a4703de675689bee2b82f

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require "helper"
require "fluent/plugin/filter_wodby.rb"

class WodbyFilterTest < Test::Unit::TestCase
  setup do
    Fluent::Test.setup
  end

  private

  def create_driver(conf)
    Fluent::Test::Driver::Filter.new(Fluent::Plugin::WodbyFilter).configure(conf)
  end

  test 'filter' do
    d = create_driver("api_key #{ENV['WODBY_API_KEY']}")
    time = event_time
    d.run do
      d.feed('filter.test', time, { 'kubernetes.namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a', 'message' => 'hullo' })
      d.feed('filter.test', time, { 'kubernetes.namespace_name' => 'a3d67f12-8341-4245-87db-ed7a6c856e70', 'message' => 'hullo' })
      d.feed('filter.test', time, { 'kubernetes.namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a', 'message' => 'hullo' })
    end

    assert_equal(3, d.filtered_records.size)
    assert_equal('dfo.no-staging', d.filtered_records[0]['wodby.instance'])
    assert_equal('dfo.no-prod', d.filtered_records[1]['wodby.instance'])
    assert_equal('dfo.no-staging', d.filtered_records[2]['wodby.instance'])
    assert_nil(d.filtered_records[2]['wodby.instance_query'])
    assert_true(d.filtered_records[0]['wodby.filter'])
    assert_true(d.filtered_records[1]['wodby.filter'])
    assert_true(d.filtered_records[2]['wodby.filter'])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluent-plugin-wodby-0.1.6 test/plugin/test_filter_wodby.rb
fluent-plugin-wodby-0.1.5 test/plugin/test_filter_wodby.rb
fluent-plugin-wodby-0.1.4 test/plugin/test_filter_wodby.rb
fluent-plugin-wodby-0.1.3 test/plugin/test_filter_wodby.rb