diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-07-11 10:19:31 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-07-11 10:19:31 -0500 |
commit | 27c8422ceede478b40c297c2ae4f51c928ee6c72 (patch) | |
tree | a1764e7ad2b584165c8966a9ee9471cf10c20710 | |
parent | ca3774181b7cef62b4dcc40ed03d92b43aab47ca (diff) | |
download | app-termcast-27c8422ceede478b40c297c2ae4f51c928ee6c72.tar.gz app-termcast-27c8422ceede478b40c297c2ae4f51c928ee6c72.zip |
add a few more tests for functionality
-rw-r--r-- | t/001-basic.t | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/t/001-basic.t b/t/001-basic.t index a8867a9..81c7037 100644 --- a/t/001-basic.t +++ b/t/001-basic.t @@ -3,29 +3,40 @@ use strict; use warnings; use Test::More; use App::Termcast; +use IO::Pty::Easy; BEGIN { eval "use Test::TCP;"; plan skip_all => "Test::TCP is required for this test" if $@; - plan tests => 1; + plan tests => 3; } test_tcp( client => sub { my $port = shift; - my $tc = App::Termcast->new(host => '127.0.0.1', port => $port, + my $client_script = <<EOF; + use App::Termcast; + my \$tc = App::Termcast->new(host => '127.0.0.1', port => $port, user => 'test', password => 'tset', extra_argv => ["$^X", "-e", "print 'foo'"]); - $tc->run; + \$tc->run; +EOF + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $client_script); + is($pty->read, 'foo', 'got the right thing on stdout'); + sleep 1; # because the server gets killed when the client exits }, server => sub { my $port = shift; my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', LocalPort => $port, Listen => 1); - $sock->accept; + $sock->accept; # signal to the client that the port is available my $client = $sock->accept; my $login; $client->recv($login, 4096); is($login, "hello test tset\n", 'got the correct login info'); + my $output; + $client->recv($output, 4096); + is($output, "foo", 'sent the right data to the server'); }, ); |