Sha256: ee24f1db3187f9207f5cef95a05ac7b3018450c5655711690aca682122c15a9e

Contents?: true

Size: 1.82 KB

Versions: 4

Compression:

Stored size: 1.82 KB

Contents

require 'test_helper'
require 'fluent/plugin/in_mongo_tail'

class MongoTailInputTest < Test::Unit::TestCase
  def setup
    Fluent::Test.setup
  end

  CONFIG = %[
    type mongo_tail
    database test
    collection log
    tag_key tag
    time_key time
    id_store_file /tmp/fluent_mongo_last_id
    id_store_collection test_last_id
  ]

  def create_driver(conf = CONFIG)
    Fluent::Test::InputTestDriver.new(Fluent::MongoTailInput).configure(conf)
  end

  def test_configure
    d = create_driver
    assert_equal('localhost', d.instance.host)
    assert_equal(27017, d.instance.port)
    assert_equal('test', d.instance.database)
    assert_equal('log', d.instance.collection)
    assert_equal('tag', d.instance.tag_key)
    assert_equal('time', d.instance.time_key)
    assert_equal('/tmp/fluent_mongo_last_id', d.instance.id_store_file)
    assert_equal('test_last_id', d.instance.id_store_collection)
  end
  
  def test_url_configration
    config = %[
    type mongo_tail
    url mongodb://localhost:27017/test
    collection log
    tag_key tag
    time_key time
    id_store_file /tmp/fluent_mongo_last_id
    ]
    
    d = create_driver(config)
    assert_equal("mongodb://localhost:27017/test", d.instance.url)
    assert_nil(d.instance.database)
    assert_equal('log', d.instance.collection)
    assert_equal('tag', d.instance.tag_key)
    assert_equal('time', d.instance.time_key)
    assert_equal('/tmp/fluent_mongo_last_id', d.instance.id_store_file)
  end

  def test_url_and_database_can_not_exist
    config = %[
    type mongo_tail
    url mongodb://localhost:27017/test
    database test2
    collection log
    tag_key tag
    time_key time
    id_store_file /tmp/fluent_mongo_last_id
    ]

    assert_raises Fluent::ConfigError do
      create_driver(config)
    end
  end

  def test_emit
    # TODO: write actual code
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluent-plugin-mongo-0.7.16 test/plugin/in_mongo_tail.rb
fluent-plugin-mongo-0.7.15 test/plugin/in_mongo_tail.rb
fluent-plugin-mongo-0.7.14 test/plugin/in_mongo_tail.rb
fluent-plugin-mongo-0.7.13 test/plugin/in_mongo_tail.rb