summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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