From e9b33a69f09a5408e2fb879f7fec2eaa68b5ca9e Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 25 Feb 2013 17:11:02 +0000 Subject: Added port-guessing test. --- t/test-custodian-testfactory.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/t/test-custodian-testfactory.rb b/t/test-custodian-testfactory.rb index 953016e..51b066d 100755 --- a/t/test-custodian-testfactory.rb +++ b/t/test-custodian-testfactory.rb @@ -86,6 +86,38 @@ class TestTestFactory < Test::Unit::TestCase + # + # Test port-guessing. + # + def test_port_detection + data = { + "foo must run ftp." => "21", + "foo must run ssh." => "22", + "foo must run mysql otherwise 'alert'" => "3306", + "foo must run redis otherwise 'alert'" => "6379", + "foo must run mysql on 33 otherwise 'alert'" => "33", + } + + # + # Run each test + # + data.each do |str,prt| + assert_nothing_raised do + + obj = Custodian::TestFactory.create( str ) + + # + # Ensure we got the object, and the port was correct. + # + assert(obj, "created object via TestFactory.create('#{str}')") + assert( obj.port().to_s == prt , "'#{str}' gave expected port '#{prt}'.") + end + end + + end + + + # # Test the rsync-test creation. # -- cgit v1.2.1