| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use Net::SSH::Tunnel; | ||
| 6 | use Data::Dumper; | ||
| 7 | use Test::More qw/no_plan/; | ||
| 8 | |||
| 9 | BEGIN { use_ok( 'Net::SSH::Tunnel' ); } | ||
| 10 | |||
| 11 | print "Hostname: "; | ||
| 12 | chomp( my $hostname = <STDIN> ); | ||
| 13 | print "Host: "; | ||
| 14 | chomp( my $host = <STDIN> ); | ||
| 15 | print "Tunnel type: "; | ||
| 16 | chomp( my $type = <STDIN>) ; | ||
| 17 | |||
| 18 | # emulating how command-line args are passed in | ||
| 19 | my $args = { | ||
| 20 | '--hostname' => $hostname, | ||
| 21 | '--host' => $host, | ||
| 22 | '--type' => $type, | ||
| 23 | }; | ||
| 24 | |||
| 25 | # stuffing them into @ARGV for the module to handle | ||
| 26 | unshift @ARGV, %{ $args }; | ||
| 27 | |||
| 28 | my $obj = Net::SSH::Tunnel->run(); | ||
| 29 | my $pid = $obj->check_tunnel(); | ||
| 30 | |||
| 31 | like( $pid, qr/^\d+$/, "check_tunnel() test to see if a tunnel has been established" ); | ||
| 32 | |||
| 33 | $obj->destroy_tunnel(); | ||
| 34 | $pid = $obj->check_tunnel(); | ||
| 35 | |||
| 36 | is( $pid, undef, "check_tunnel() test to see if a tunnel has been destroyed" ); |