X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei-externals.t;h=2045691fa5c155a25e9891efdd7a5c2280c0b19c;hb=7d2e572aca7297ea2015d2b6e7c71b672521ec82;hp=b78b5580000e5dfe7b5738cb26fe5774d47ebeed;hpb=ac6c31a84fc9ef363bca6838c40a2bf30f49e43e;p=public-inbox.git diff --git a/t/lei-externals.t b/t/lei-externals.t index b78b5580..2045691f 100644 --- a/t/lei-externals.t +++ b/t/lei-externals.t @@ -25,7 +25,7 @@ SKIP: { lei_ok(@cmd, \"query $url"); is($lei_err, '', "no errors on $url"); my $res = json_utf8->decode($lei_out); - is($res->[0]->{'m'}, "<$mid>", "got expected mid from $url") or + is($res->[0]->{'m'}, $mid, "got expected mid from $url") or skip 'further remote tests', 1; lei_ok(@cmd, 'd:..20101002', \'no results, no error'); is($lei_err, '', 'no output on 404, matching local FS behavior'); @@ -40,7 +40,7 @@ SKIP: { pipe(my ($r, $w)) or BAIL_OUT $!; open my $err, '+>', undef or BAIL_OUT $!; my $opt = { run_mode => 0, 1 => $w, 2 => $err }; - my $cmd = [qw(lei q -qt), @$out, 'bytes:1..']; + my $cmd = [qw(lei q -qt), @$out, 'z:1..']; my $tp = start_script($cmd, undef, $opt); close $w; sysread($r, my $buf, 1); @@ -78,8 +78,12 @@ test_lei(sub { ok(!-e $config_file && !-e $store_dir, 'nothing created by ls-external'); - ok(!lei('add-external', "$home/nonexistent", - "fails on non-existent dir")); + ok(!lei('add-external', "$home/nonexistent"), + "fails on non-existent dir"); + like($lei_err, qr/not a directory/, 'noted non-existence'); + mkdir "$home/new\nline" or BAIL_OUT "mkdir: $!"; + ok(!lei('add-external', "$home/new\nline"), "fails on newline"); + like($lei_err, qr/`\\n' not allowed/, 'newline noted in error'); lei_ok('ls-external', \'ls-external works after add failure'); is($lei_out.$lei_err, '', 'ls-external still has no output'); my $cfg = PublicInbox::Config->new($cfg_path); @@ -123,8 +127,10 @@ test_lei(sub { lei_ok qw(_complete lei forget-external), \'complete for externals'; my %comp = map { $_ => 1 } split(/\s+/, $lei_out); ok($comp{'https://example.com/ibx/'}, 'forget external completion'); + my @dirs; $cfg->each_inbox(sub { my ($ibx) = @_; + push @dirs, $ibx->{inboxdir}; ok($comp{$ibx->{inboxdir}}, "local $ibx->{name} completion"); }); for my $u (qw(h http https https: https:/ https:// https://e @@ -153,7 +159,8 @@ test_lei(sub { lei_ok('ls-external'); unlike($lei_out, qr!https://example\.com/ibx/!s, 'removed canonical URL'); -SKIP: { + + # do some queries ok(!lei(qw(q s:prefix -o maildir:/dev/null)), 'bad maildir'); like($lei_err, qr!/dev/null exists and is not a directory!, 'error shown'); @@ -229,7 +236,8 @@ SKIP: { is(scalar(@s), 2, "2 results in mbox$sfx"); lei_ok('q', '-a', '-o', "mboxcl2:$f", 's:nonexistent'); - is(grep(!/^#/, $lei_err), 0, "no errors on no results ($sfx)"); + is(grep(!/^#/, $lei_err), 0, "no errors on no results ($sfx)") + or diag $lei_err; my @s2 = grep(/^Subject:/, $cat->()); is_deeply(\@s2, \@s, @@ -245,6 +253,15 @@ SKIP: { is($? >> 8, 1, 'proper exit code'); like($lei_err, qr/no local or remote.+? to search/, 'no inbox'); + for my $no (['--no-local'], ['--no-external'], + [qw(--no-local --no-external)]) { + lei_ok(qw(q mid:testmessage@example.com), @$no, + '-I', $dirs[0], \"-I and @$no combine"); + $res = json_utf8->decode($lei_out); + is($res->[0]->{'m'}, 'testmessage@example.com', + "-I \$DIR got results regardless of @$no"); + } + { opendir my $dh, '.' or BAIL_OUT "opendir(.) $!"; my $od = PublicInbox::OnDestroy->new($$, sub { @@ -274,6 +291,5 @@ SKIP: { $url = $e{$k} if $url eq '1'; $test_external_remote->($url, $k); } - }; # /SKIP }); # test_lei done_testing;