Guest User

Untitled

a guest
Aug 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. require 'fluent/test'
  2. require 'fluent/plugin/out_redis'
  3.  
  4. class FileOutputTest < Test::Unit::TestCase
  5.  
  6. def setup
  7. Fluent::Test.setup
  8.  
  9. @d = create_driver %[
  10. host localhost
  11. port 6379
  12. db_number 1
  13. ]
  14. @time = Time.parse("2011-01-02 13:14:15 UTC").to_i
  15. end
  16.  
  17. def create_driver(conf = CONFIG)
  18. Fluent::Test::BufferedOutputTestDriver.new(Fluent::RedisOutput).configure(conf)
  19. end
  20.  
  21. def test_configure
  22. assert_equal 'localhost', @d.instance.host
  23. assert_equal 6379, @d.instance.port
  24. assert_equal 1, @d.instance.db_number
  25. end
  26.  
  27. def test_format
  28. @d.emit({"a"=>1}, @time)
  29. @d.expect_format(["test.#{@time}", {"a"=>1}].to_msgpack)
  30. @d.run
  31. end
  32.  
  33. def test_write
  34. @d.emit({"a"=>2}, @time)
  35. @d.emit({"a"=>3}, @time)
  36. @d.run
  37.  
  38. assert_equal "2", @d.instance.redis.hget("test.#{@time}.0", "a")
  39. assert_equal "3", @d.instance.redis.hget("test.#{@time}.1", "a")
  40. end
  41. end
Add Comment
Please, Sign In to add comment