]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/nntpd.t: additional tests for XHDR/HDR
authorEric Wong <e@80x24.org>
Wed, 30 Sep 2015 21:00:27 +0000 (21:00 +0000)
committerEric Wong <e@80x24.org>
Wed, 30 Sep 2015 21:09:25 +0000 (21:09 +0000)
More testing is good, especially since clients I use
don't implement all the commands.

t/nntpd.t

index 8a721e2098eb5556a8022fa1f22d4b3afb2304cb..ecb876f9d49dd9b0f32dbc947a6c98d5b3153782 100644 (file)
--- 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);