Sha256: 5b44c922e984c1cb864299ef8fdff29b1a646cee498a5a6421fb0bb50df8cda3

Contents?: true

Size: 896 Bytes

Versions: 4

Compression:

Stored size: 896 Bytes

Contents

require 'fluent/test'

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
  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

4 entries across 4 versions & 4 rubygems

Version Path
fluent-plugin-redis-list-0.0.1 test/plugin/out_redis.rb
fluent-plugin-redis-url-tracker-0.2.1 test/plugin/out_redis.rb
fluent-plugin-redislist-0.0.1 test/plugin/out_redis.rb
fluent-plugin-redis-0.2.0 test/plugin/out_redis.rb