From 58c7600f8fc4d9970793a214c22cab52540968f7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 30 Sep 2015 21:00:27 +0000 Subject: t/nntpd.t: additional tests for XHDR/HDR More testing is good, especially since clients I use don't implement all the commands. --- t/nntpd.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 't') diff --git a/t/nntpd.t b/t/nntpd.t index 8a721e20..ecb876f9 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -176,6 +176,25 @@ EOF is($r[2], '.', 'correctly terminated response'); } + is_deeply($n->xhdr(qw(Cc 1-)), { 1 => 'test-nntpd@example.com' }, + 'XHDR Cc 1- works'); + is_deeply($n->xhdr(qw(References 1-)), { 1 => '' }, + 'XHDR References 1- works (empty string)'); + is_deeply($n->xhdr(qw(list-id 1-)), {}, + 'XHDR on invalid header returns empty'); + + { + syswrite($s, "HDR List-id 1-\r\n"); + $buf = ''; + do { + sysread($s, $buf, 4096, length($buf)); + } until ($buf =~ /\r\n\z/); + my @r = split("\r\n", $buf); + like($r[0], qr/^5\d\d /, + 'got 5xx response for unoptimized HDR'); + is(scalar @r, 1, 'only one response line'); + } + ok(kill('TERM', $pid), 'killed nntpd'); $pid = undef; waitpid(-1, 0); -- cgit v1.2.3-24-ge0c7