Sha256: 6d46291ad4ebdd5c20a69d72b904199b875100b28d163a24b1d91eb5cc090157

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'fluent/test'
require 'fluent/plugin/out_redis'

class FileOutputTest < Test::Unit::TestCase
  def setup
    Fluent::Test.setup

    @d = create_driver %[
      host localhost
      port 6379
      db_number 1
    ]
    @time = Time.parse("2011-01-02 13:14:15 UTC").to_i
  end

  def create_driver(conf = CONFIG)
    Fluent::Test::BufferedOutputTestDriver.new(Fluent::RedisOutput).configure(conf)
  end

  def test_configure
    assert_equal 'localhost', @d.instance.host
    assert_equal 6379, @d.instance.port
    assert_equal 1, @d.instance.db_number
    assert_nil @d.instance.password
  end

  def test_configure_with_password
    d = create_driver %[
      host localhost
      port 6379
      db_number 1
      password testpass
    ]
    assert_equal 'localhost', d.instance.host
    assert_equal 6379, d.instance.port
    assert_equal 1, d.instance.db_number
    assert_equal 'testpass', d.instance.password
  end

  def test_format
    @d.emit({"a"=>1}, @time)
    @d.expect_format(["test.#{@time}", {"a"=>1}].to_msgpack)
    @d.run
  end

  def test_write
    @d.emit({"a"=>2}, @time)
    @d.emit({"a"=>3}, @time)
    @d.run

    assert_equal "2", @d.instance.redis.hget("test.#{@time}.0", "a")
    assert_equal "3", @d.instance.redis.hget("test.#{@time}.1", "a")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-redis-0.2.3 test/plugin/test_out_redis.rb
fluent-plugin-redis-0.2.2 test/plugin/test_out_redis.rb