diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-23 14:03:18 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-23 14:03:18 +0000 |
commit | f5f6cd4d0ff8d1cacf4022c71a5814a362bfe6eb (patch) | |
tree | 38f39033d31b12601b8a4aaab5dbf8a3b41392fa /t/test-custodian-testfactory.rb | |
parent | 755a8885a68233450eec40de19606aa30358b9b1 (diff) |
Test port-detection
Diffstat (limited to 't/test-custodian-testfactory.rb')
-rwxr-xr-x | t/test-custodian-testfactory.rb | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/t/test-custodian-testfactory.rb b/t/test-custodian-testfactory.rb index 7ef44b1..383b0f0 100755 --- a/t/test-custodian-testfactory.rb +++ b/t/test-custodian-testfactory.rb @@ -35,6 +35,7 @@ class TestTestFactory < Test::Unit::TestCase # Test the FTP-test may be created # def test_ftp_uri + assert_nothing_raised do assert( Custodian::TestFactory.create( "ftp.example.com must run ftp." ) ) assert( Custodian::TestFactory.create( "ftp://ftp.example.com/ must run ftp." ) ) @@ -47,11 +48,80 @@ class TestTestFactory < Test::Unit::TestCase assert( Custodian::TestFactory.create( "ftp://ftp.example.com/ must run ftp." ).target() == "ftp.example.com" ) + # + # Test the port detection + # + data = { + "foo must run ftp." => "21", + "ftp://ftp.example.com/ must run ftp." => "21", + "foo must run ftp on 1 otherwise 'x'." => "1", + "foo must run ftp on 33 otherwise" => "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. + # + def test_rsync_uri - assert( Custodian::TestFactory.create( "rsync.example.com must run rsync." ).target() == "rsync.example.com" ) - assert( Custodian::TestFactory.create( "rsync://rsync.example.com/ must run rsync." ).target() == "rsync.example.com" ) + assert_nothing_raised do + assert( Custodian::TestFactory.create( "example.com must run rsync." ) ) + assert( Custodian::TestFactory.create( "ftp://example.com/ must run rsync." ) ) + assert( Custodian::TestFactory.create( "ftp://example.com/ must run rsync on 333." ) ) + assert( Custodian::TestFactory.create( "ftp://example.com/ must run rsync on 3311 otherwise 'xxx'." ) ) + end + assert( Custodian::TestFactory.create( "rsync.example.com must run rsync." ).target() == + "rsync.example.com" ) + assert( Custodian::TestFactory.create( "rsync://rsync.example.com/ must run rsync." ).target() == + "rsync.example.com" ) + + + # + # Test the ports + # + data = { + "foo must run rsync." => "873", + "rsync://foo/ must run rsync." => "873", + "foo must run rsync on 1 otherwise 'x'." => "1", + "foo must run rsync on 33 otherwise" => "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 |