test/plugin/test_out_redis.rb in fluent-plugin-redis-0.3.1 vs test/plugin/test_out_redis.rb in fluent-plugin-redis-0.3.2

- old
+ new

@@ -34,10 +34,11 @@ assert_equal 1, @d.instance.db_number assert_nil @d.instance.password assert_equal '${tag}', @d.instance.insert_key_prefix assert_equal '%s', @d.instance.strftime_format assert_false @d.instance.allow_duplicate_key + assert_equal Fluent::Plugin::RedisOutput::DEFAULT_TTL_VALUE, @d.instance.ttl end def test_configure_with_password d = create_driver CONFIG + %[ password testpass @@ -114,11 +115,28 @@ d.run(default_tag: 'prefix.insert.test') do d.feed(time, {"a"=>2}) d.feed(time, {"a"=>3}) end - assert_equal "2", d.instance.redis.hget("insert.test.#{time}.0", "a") - assert_equal "3", d.instance.redis.hget("insert.test.#{time}.1", "a") + assert_equal "2", d.instance.redis.hget("test.#{time}.0", "a") + assert_equal "3", d.instance.redis.hget("test.#{time}.1", "a") + end + + def test_write_with_ttl + ttl = 2 + d = create_driver CONFIG + %[ + ttl #{ttl} + allow_duplicate_key true + ] + time = event_time("2011-01-02 13:14:00 UTC") + d.run(default_tag: 'ttl.insert.test') do + d.feed(time, {"a"=>2}) + end + + assert_in_delta 2.0, d.instance.redis.ttl("ttl.insert.test"), 1.0 + + sleep ttl+1 + assert_equal -2, d.instance.redis.ttl("ttl.insert.test") end def test_write_with_custom_strftime_format d = create_driver CONFIG + %[ strftime_format "%Y%m%d.%H%M%S"