summaryrefslogtreecommitdiffstats
path: root/t/write-to-termcast.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-04-14 09:07:23 -0500
committerJesse Luehrs <doy@tozt.net>2011-04-14 09:07:23 -0500
commit719e6746ab3ef0c6a0557fb063d7b7748a845a59 (patch)
treecd9092e169b2f604be34296429ded20b7df58deb /t/write-to-termcast.t
parent9d99f3ccfd4b4aa83fa09d6beaa0589c01eecbda (diff)
downloadapp-termcast-719e6746ab3ef0c6a0557fb063d7b7748a845a59.tar.gz
app-termcast-719e6746ab3ef0c6a0557fb063d7b7748a845a59.zip
remove test numbering
Diffstat (limited to 't/write-to-termcast.t')
-rw-r--r--t/write-to-termcast.t56
1 files changed, 56 insertions, 0 deletions
diff --git a/t/write-to-termcast.t b/t/write-to-termcast.t
new file mode 100644
index 0000000..47321ec
--- /dev/null
+++ b/t/write-to-termcast.t
@@ -0,0 +1,56 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Requires 'Test::TCP';
+
+use App::Termcast;
+
+no warnings 'redefine';
+local *App::Termcast::_termsize = sub { return (80, 24) };
+use warnings 'redefine';
+
+pipe(my $cread, my $swrite);
+pipe(my $sread, my $cwrite);
+
+test_tcp(
+ client => sub {
+ my $port = shift;
+ close $swrite;
+ close $sread;
+ { sysread($cread, my $buf, 1) }
+ my $tc = App::Termcast->new(
+ host => '127.0.0.1', port => $port,
+ user => 'test', password => 'tset');
+ $tc->write_to_termcast('foo');
+ syswrite($cwrite, 'a');
+ { sysread($cread, my $buf, 1) }
+ ok(!$tc->meta->find_attribute_by_name('pty')->has_value($tc),
+ "pty isn't created");
+ },
+ server => sub {
+ my $port = shift;
+ close $cwrite;
+ close $cread;
+ 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
+ syswrite($swrite, 'a');
+ my $client = $sock->accept;
+ my $login;
+ $client->recv($login, 4096);
+ is($login,
+ "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J",
+ "got the correct login info");
+ $client->send("hello, test\n");
+ { sysread($sread, my $buf, 1) }
+
+ my $buf;
+ $client->recv($buf, 4096);
+ is($buf, 'foo', 'wrote correctly');
+ syswrite($swrite, 'a');
+ },
+);
+
+done_testing;