test/plugin/test_out_slack.rb in fluent-plugin-slack-0.5.0 vs test/plugin/test_out_slack.rb in fluent-plugin-slack-0.5.1

- old
+ new

@@ -81,10 +81,25 @@ end assert_raise(Fluent::ConfigError) do create_driver(CONFIG + %[channel %s %s\nchannel_keys foo]) end + + # Either of webhook_url or token is required + assert_raise(Fluent::ConfigError) do + create_driver(%[channel foo]) + end + + # webhook_url is an empty string + assert_raise(Fluent::ConfigError) do + create_driver(%[channel foo\nwebhook_url]) + end + + # token is an empty string + assert_raise(Fluent::ConfigError) do + create_driver(%[channel foo\ntoken]) + end end def test_timezone_configure time = Time.parse("2014-01-01 22:00:00 UTC").to_i @@ -127,11 +142,11 @@ channel channel webhook_url https://hooks.slack.com/services/XXX/XXX/XXX ]) time = Time.parse("2014-01-01 22:00:00 UTC").to_i d.tag = 'test' - mock(d.instance.slack).post_message( + mock(d.instance.slack).post_message({ channel: '#channel', username: 'fluentd', icon_emoji: ':question:', attachments: [{ color: 'good', @@ -139,11 +154,11 @@ fields: [{ title: 'test', value: "[07:00:00] sowawa1\n[07:00:00] sowawa2\n", }], }] - ) + }, {}) with_timezone('Asia/Tokyo') do d.emit({message: 'sowawa1'}, time) d.emit({message: 'sowawa2'}, time) d.run end @@ -154,21 +169,21 @@ channel channel token XX-XX-XX ]) time = Time.parse("2014-01-01 22:00:00 UTC").to_i d.tag = 'test' - mock(d.instance.slack).post_message( + mock(d.instance.slack).post_message({ token: 'XX-XX-XX', channel: '#channel', username: 'fluentd', icon_emoji: ':question:', attachments: [{ color: 'good', fallback: "sowawa1\nsowawa2\n", text: "sowawa1\nsowawa2\n", }] - ) + }, {}) with_timezone('Asia/Tokyo') do d.emit({message: 'sowawa1'}, time) d.emit({message: 'sowawa2'}, time) d.run end @@ -177,11 +192,11 @@ def test_title_keys d = create_driver(CONFIG + %[title %s\ntitle_keys tag]) time = Time.parse("2014-01-01 22:00:00 UTC").to_i d.tag = 'test' # attachments field should be changed to show the title - mock(d.instance.slack).post_message( + mock(d.instance.slack).post_message({ token: 'XXX-XXX-XXX', channel: '#channel', username: 'fluentd', icon_emoji: ':question:', attachments: [{ @@ -192,11 +207,11 @@ title: d.tag, value: "sowawa1\nsowawa2\n", } ] }] - ) + }, {}) with_timezone('Asia/Tokyo') do d.emit({message: 'sowawa1'}, time) d.emit({message: 'sowawa2'}, time) d.run end @@ -204,21 +219,21 @@ def test_message_keys d = create_driver(CONFIG + %[message %s %s\nmessage_keys tag,message]) time = Time.parse("2014-01-01 22:00:00 UTC").to_i d.tag = 'test' - mock(d.instance.slack).post_message( + mock(d.instance.slack).post_message({ token: 'XXX-XXX-XXX', channel: '#channel', username: 'fluentd', icon_emoji: ':question:', attachments: [{ color: 'good', fallback: "test sowawa1\ntest sowawa2\n", text: "test sowawa1\ntest sowawa2\n", }] - ) + }, {}) with_timezone('Asia/Tokyo') do d.emit({message: 'sowawa1'}, time) d.emit({message: 'sowawa2'}, time) d.run end @@ -226,31 +241,31 @@ def test_channel_keys d = create_driver(CONFIG + %[channel %s\nchannel_keys channel]) time = Time.parse("2014-01-01 22:00:00 UTC").to_i d.tag = 'test' - mock(d.instance.slack).post_message( + mock(d.instance.slack).post_message({ token: 'XXX-XXX-XXX', channel: '#channel1', username: 'fluentd', icon_emoji: ':question:', attachments: [{ color: 'good', fallback: "sowawa1\n", text: "sowawa1\n", }] - ) - mock(d.instance.slack).post_message( + }, {}) + mock(d.instance.slack).post_message({ token: 'XXX-XXX-XXX', channel: '#channel2', username: 'fluentd', icon_emoji: ':question:', attachments: [{ color: 'good', fallback: "sowawa2\n", text: "sowawa2\n", }] - ) + }, {}) with_timezone('Asia/Tokyo') do d.emit({message: 'sowawa1', channel: 'channel1'}, time) d.emit({message: 'sowawa2', channel: 'channel2'}, time) d.run end