From 529ed432f68d108fb0213e462d87f72bdaf4a6f3 Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Tue, 27 Mar 2012 16:51:50 -0400 Subject: [PATCH] Cleans up some tests --- lib/fluent/plugin/out_apns.rb | 2 +- test/plugin/out_apns_test.rb | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/fluent/plugin/out_apns.rb b/lib/fluent/plugin/out_apns.rb index e89ec32..3ce3382 100644 --- a/lib/fluent/plugin/out_apns.rb +++ b/lib/fluent/plugin/out_apns.rb @@ -14,7 +14,7 @@ def configure(conf) @host = conf.fetch('host') { 'gateway.sandbox.push.apple.com' } @port = conf.fetch('port') { 2195 }.to_i - @pem = conf.fetch('pem') { raise Fluent::ConfigError } + @pem = conf.fetch('pem') { raise Fluent::ConfigError, "pem is a required attribute" } @password = conf.fetch('password') { nil } @apns = ApnServer::Client.new(@pem, @host, @port, @password) diff --git a/test/plugin/out_apns_test.rb b/test/plugin/out_apns_test.rb index d1e8eac..c47f317 100644 --- a/test/plugin/out_apns_test.rb +++ b/test/plugin/out_apns_test.rb @@ -6,6 +6,16 @@ def setup require 'fluent/plugin/out_apns' end + def default_configuration + <<-EOC + pem /root/.ssh/apns.pem + EOC + end + + def empty_configuration + '' + end + def create_driver(conf = '') Fluent::Test::BufferedOutputTestDriver.new(Fluent::ApnsOutput).configure(conf) end @@ -27,21 +37,16 @@ def test_configure_options end def test_configure_defaults - conf = ' - pem /root/.ssh/apns.pem - ' - - driver = create_driver(conf) + driver = create_driver(default_configuration) assert_equal(driver.instance.host, 'gateway.sandbox.push.apple.com') assert_equal(driver.instance.port, 2195) - assert_equal(driver.instance.pem, '/root/.ssh/apns.pem') assert_equal(driver.instance.password, nil) end def test_configure_without_pem assert_raise Fluent::ConfigError do - create_driver + create_driver(empty_configuration) end end end