test/plugin/test_in_twitter.rb in fluent-plugin-twitter-0.6.0 vs test/plugin/test_in_twitter.rb in fluent-plugin-twitter-0.6.1

- old
+ new

@@ -1,6 +1,8 @@ require 'helper' +require 'fluent/plugin/in_twitter' +require 'fluent/test/driver/input' class TwitterInputTest < Test::Unit::TestCase def setup Fluent::Test.setup end @@ -12,49 +14,59 @@ access_token_secret ACCESS_TOKEN_SECRET tag input.twitter timeline sampling ] - def create_driver(conf=CONFIG,tag='test',use_v1=false) - Fluent::Test::OutputTestDriver.new(Fluent::TwitterInput, tag).configure(conf,use_v1) + def create_driver(conf = CONFIG, syntax: :v1) + Fluent::Test::Driver::Input.new(Fluent::Plugin::TwitterInput).configure(conf, syntax: syntax) end - def test_configure - assert_raise(Fluent::ConfigError) { - d = create_driver('') - } - d = create_driver %[ - consumer_key CONSUMER_KEY - consumer_secret CONSUMER_SECRET - access_token ACCESS_TOKEN - access_token_secret ACCESS_TOKEN_SECRET - tag input.twitter - timeline tracking - keyword ${hashtag}fluentd,fluentd lang:ja - ] - assert_equal 'CONSUMER_KEY', d.instance.consumer_key - assert_equal 'CONSUMER_SECRET', d.instance.consumer_secret - assert_equal 'ACCESS_TOKEN', d.instance.access_token - assert_equal 'ACCESS_TOKEN_SECRET', d.instance.access_token_secret - assert_equal '#fluentd,fluentd lang:ja', d.instance.keyword + sub_test_case "v0 syntax" do + def test_empty + assert_raise(Fluent::ConfigError) { + create_driver('', syntax: :v0) + } + end + + def test_configure + d = create_driver %[ + consumer_key CONSUMER_KEY + consumer_secret CONSUMER_SECRET + access_token ACCESS_TOKEN + access_token_secret ACCESS_TOKEN_SECRET + tag input.twitter + timeline tracking + keyword ${hashtag}fluentd,fluentd lang:ja + ] + assert_equal 'CONSUMER_KEY', d.instance.consumer_key + assert_equal 'CONSUMER_SECRET', d.instance.consumer_secret + assert_equal 'ACCESS_TOKEN', d.instance.access_token + assert_equal 'ACCESS_TOKEN_SECRET', d.instance.access_token_secret + assert_equal '#fluentd,fluentd lang:ja', d.instance.keyword + end end - def test_v1_multi_keyword - assert_raise(Fluent::ConfigError) { - d = create_driver('', 'test', true) - } - d = create_driver(%[ - consumer_key CONSUMER_KEY - consumer_secret CONSUMER_SECRET - access_token ACCESS_TOKEN - access_token_secret ACCESS_TOKEN_SECRET - tag input.twitter - timeline tracking - keyword 'treasuredata,treasure data,#treasuredata,fluentd,#fluentd' - ], 'test', true) - assert_equal 'CONSUMER_KEY', d.instance.consumer_key - assert_equal 'CONSUMER_SECRET', d.instance.consumer_secret - assert_equal 'ACCESS_TOKEN', d.instance.access_token - assert_equal 'ACCESS_TOKEN_SECRET', d.instance.access_token_secret - assert_equal 'treasuredata,treasure data,#treasuredata,fluentd,#fluentd', d.instance.keyword + sub_test_case "v1 syntax" do + def test_empty + assert_raise(Fluent::ConfigError) { + create_driver('') + } + end + + def test_multi_keyword + d = create_driver(%[ + consumer_key CONSUMER_KEY + consumer_secret CONSUMER_SECRET + access_token ACCESS_TOKEN + access_token_secret ACCESS_TOKEN_SECRET + tag input.twitter + timeline tracking + keyword 'treasuredata,treasure data,#treasuredata,fluentd,#fluentd' + ]) + assert_equal 'CONSUMER_KEY', d.instance.consumer_key + assert_equal 'CONSUMER_SECRET', d.instance.consumer_secret + assert_equal 'ACCESS_TOKEN', d.instance.access_token + assert_equal 'ACCESS_TOKEN_SECRET', d.instance.access_token_secret + assert_equal 'treasuredata,treasure data,#treasuredata,fluentd,#fluentd', d.instance.keyword + end end end