diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-04-18 19:15:33 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-04-18 19:15:33 -0500 |
commit | 50c4cf92c44b5e2cd0c438a5a1e5ecdbc53ba3c6 (patch) | |
tree | 0329d37a11c878d4afb9af6727128a197f229a38 /t | |
parent | 028486526465f344cbc60ab01f7612ecacaaa9f8 (diff) | |
download | app-termcast-50c4cf92c44b5e2cd0c438a5a1e5ecdbc53ba3c6.tar.gz app-termcast-50c4cf92c44b5e2cd0c438a5a1e5ecdbc53ba3c6.zip |
test the write_to_termcast method
Diffstat (limited to 't')
-rw-r--r-- | t/003-write-to-termcast.t | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/t/003-write-to-termcast.t b/t/003-write-to-termcast.t new file mode 100644 index 0000000..04045cf --- /dev/null +++ b/t/003-write-to-termcast.t @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use App::Termcast; +BEGIN { + eval "use Test::TCP;"; + plan skip_all => "Test::TCP is required for this test" if $@; + plan tests => 3; +} + +test_tcp( + client => sub { + my $port = shift; + my $tc = App::Termcast->new( + host => '127.0.0.1', port => $port, + user => 'test', password => 'tset'); + $tc->write_to_termcast('foo'); + ok(!$tc->meta->find_attribute_by_name('pty')->has_value($tc), + "pty isn't created"); + sleep 1; + }, + server => sub { + my $port = shift; + my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', + LocalPort => $port, + Listen => 1); + $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 $buf; + $client->recv($buf, 4096); + is($buf, 'foo', 'wrote correctly'); + }, +); |