]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/nntpd.t
fixup Plack-related requires
[public-inbox.git] / t / nntpd.t
index 8a721e2098eb5556a8022fa1f22d4b3afb2304cb..d8c2e7b305f4563aefea6e3ab32885a51c89c1b5 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -3,10 +3,12 @@
 use strict;
 use warnings;
 use Test::More;
-eval { require PublicInbox::SearchIdx };
-plan skip_all => "Xapian missing for nntpd" if $@;
-eval { require PublicInbox::Msgmap };
-plan skip_all => "DBD::SQLite missing for nntpd" if $@;
+foreach my $mod (qw(DBD::SQLite Search::Xapian Danga::Socket)) {
+       eval "require $mod";
+       plan skip_all => "$mod missing for nntpd.t" if $@;
+}
+require PublicInbox::SearchIdx;
+require PublicInbox::Msgmap;
 use Cwd;
 use Email::Simple;
 use IO::Socket;
@@ -15,7 +17,6 @@ use Socket qw(SO_KEEPALIVE IPPROTO_TCP TCP_NODELAY);
 use File::Temp qw/tempdir/;
 use Net::NNTP;
 use IPC::Run qw(run);
-use Data::Dumper;
 
 my $tmpdir = tempdir(CLEANUP => 1);
 my $home = "$tmpdir/pi-home";
@@ -176,6 +177,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);