Permalink
Browse files

Cleans up some tests

  • Loading branch information...
1 parent 06afe97 commit 529ed432f68d108fb0213e462d87f72bdaf4a6f3 @alindeman alindeman committed Mar 27, 2012
Showing with 13 additions and 8 deletions.
  1. +1 −1 lib/fluent/plugin/out_apns.rb
  2. +12 −7 test/plugin/out_apns_test.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)
@@ -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

0 comments on commit 529ed43

Please sign in to comment.