spec/out_split_spec.rb in fluent-plugin-split-0.0.4 vs spec/out_split_spec.rb in fluent-plugin-split-0.1.0
- old
+ new
@@ -5,11 +5,11 @@
def setup
Fluent::Test.setup
end
def create_driver(conf = CONFIG, tag = 'test')
- d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::SplitOutput, tag).configure(conf)
+ d = Fluent::Test::OutputTestDriver.new(Fluent::SplitOutput, tag).configure(conf)
d
end
def test_configure_error
assert_raise(Fluent::ConfigError) do
@@ -65,7 +65,27 @@
output_tag split.keyword
output_key keyword
key_name keywords
]
end
+ end
+
+ def test_emits
+ tag = "split.keyword"
+ d = create_driver %[
+ type split
+ output_tag #{tag}
+ output_key keyword
+ format csv
+ key_name keywords
+ keep_keys site
+ ], "test.split"
+
+ time = Time.now.to_i
+ d.run {
+ d.emit({"keywords"=>"keyword1,keyword2,keyword3", "site" => "google", "user_id" => "1"}, time)
+ }
+ assert_equal [[tag, time, {"keyword"=>"keyword1", "site"=>"google"}],
+ [tag, time, {"keyword"=>"keyword2", "site"=>"google"}],
+ [tag, time, {"keyword"=>"keyword3", "site"=>"google"}]], d.emits
end
end