-# Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use warnings;
require_mods(qw(DBD::SQLite));
require PublicInbox::InboxWritable;
use PublicInbox::Eml;
-use IO::Socket;
use Socket qw(IPPROTO_TCP TCP_NODELAY);
use Net::NNTP;
use Sys::Hostname;
my %opts;
my $sock = tcp_server();
+my $host_port = tcp_host_port($sock);
my $td;
my $len;
}
}
- ok($sock, 'sock created');
my $cmd = [ '-nntpd', '-W0', "--stdout=$out", "--stderr=$err" ];
$td = start_script($cmd, undef, { 3 => $sock });
- my $host_port = $sock->sockhost . ':' . $sock->sockport;
my $n = Net::NNTP->new($host_port);
my $list = $n->list;
ok(delete $list->{'x.y.z'}, 'deleted x.y.z group');
'cross newsgroup BODY by Message-ID');
ok($n->head('<testmessage@example.com>'),
'cross newsgroup HEAD by Message-ID');
+ is($n->xpath('<testmessage@example.com>'), 'x.y.z/1', 'xpath hit');
+ is($n->xpath('<non-existent@example.com>'), undef, 'xpath miss');
# pipelined requests:
{
# -compact requires Xapian
SKIP: {
require_mods('Search::Xapian', 2);
- which('xapian-compact') or skip 'xapian-compact missing', 2;
+ have_xapian_compact or skip 'xapian-compact missing', 2;
is(xsys(qw(git config), "--file=$home/.public-inbox/config",
"publicinbox.$group.indexlevel", 'medium'),
0, 'upgraded indexlevel');
my @of = xqx([$lsof, '-p', $td->{pid}], undef, $noerr);
is(scalar(grep(/\(deleted\)/, @of)), 0, 'no deleted files');
};
- SKIP: { test_watch($tmpdir, $sock, $group) };
+ SKIP: { test_watch($tmpdir, $host_port, $group) };
{
setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1);
syswrite($s, 'HDR List-id 1-');
}
sub test_watch {
- my ($tmpdir, $sock, $group) = @_;
+ my ($tmpdir, $host_port, $group) = @_;
use_ok 'PublicInbox::Watch';
use_ok 'PublicInbox::InboxIdle';
use_ok 'PublicInbox::Config';
my $url = "http://example.com/i1";
my $inboxdir = "$tmpdir/watchnntp";
my $cmd = ['-init', '-V1', '-Lbasic', $name, $inboxdir, $url, $addr];
- my ($ihost, $iport) = ($sock->sockhost, $sock->sockport);
- my $nntpurl = "nntp://$ihost:$iport/$group";
+ my $nntpurl = "nntp://$host_port/$group";
run_script($cmd) or BAIL_OUT("init $name");
xsys(qw(git config), "--file=$home/.public-inbox/config",
"publicinbox.$name.watch",