Skip to content

Commit

Permalink
Cleans up some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alindeman committed Mar 27, 2012
1 parent 06afe97 commit 529ed43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/out_apns.rb
Expand Up @@ -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)
Expand Down
19 changes: 12 additions & 7 deletions test/plugin/out_apns_test.rb
Expand Up @@ -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
Expand All @@ -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.