summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-23 14:03:18 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-23 14:03:18 +0000
commitf5f6cd4d0ff8d1cacf4022c71a5814a362bfe6eb (patch)
tree38f39033d31b12601b8a4aaab5dbf8a3b41392fa /t
parent755a8885a68233450eec40de19606aa30358b9b1 (diff)
Test port-detection
Diffstat (limited to 't')
-rwxr-xr-xt/test-custodian-testfactory.rb74
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