]> Sergey Matveev's repositories - public-inbox.git/blob - t/lei-p2q.t
doc: relnotes: 1.7.0: move extindex, note search results change
[public-inbox.git] / t / lei-p2q.t
1 #!perl -w
2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict; use v5.10.1; use PublicInbox::TestCommon;
5 require_git 2.6;
6 require_mods(qw(json DBD::SQLite Search::Xapian));
7
8 test_lei(sub {
9         ok(!lei(qw(p2q this-better-cause-format-patch-to-fail)),
10                 'p2q fails on bogus arg') or diag $lei_err;
11         like($lei_err, qr/format-patch.*failed/, 'notes format-patch failure');
12         lei_ok(qw(p2q -w dfpost t/data/0001.patch));
13         is($lei_out, "dfpost:6e006fd73b1d\n", 'pathname') or diag $lei_err;
14         open my $fh, '+<', 't/data/0001.patch' or xbail "open: $!";
15         lei_ok([qw(p2q -w dfpost -)], undef, { %$lei_opt, 0 => $fh });
16         is($lei_out, "dfpost:6e006fd73b1d\n", '--stdin') or diag $lei_err;
17
18         sysseek($fh, 0, 0) or xbail "lseek: $!";
19         lei_ok([qw(p2q -w dfpost)], undef, { %$lei_opt, 0 => $fh });
20         is($lei_out, "dfpost:6e006fd73b1d\n", 'implicit --stdin');
21
22         lei_ok(qw(p2q --uri t/data/0001.patch -w), 'dfpost,dfn');
23         is($lei_out, "dfpost%3A6e006fd73b1d+".
24                 "dfn%3Alib%2FPublicInbox%2FSearch.pm\n",
25                 '--uri -w dfpost,dfn');
26         lei_ok(qw(p2q t/data/0001.patch), '--want=dfpost,OR,dfn');
27         is($lei_out, "dfpost:6e006fd73b1d OR dfn:lib/PublicInbox/Search.pm\n",
28                 '--want=OR');
29         lei_ok(qw(p2q t/data/0001.patch --want=dfpost9));
30         is($lei_out, "dfpost:6e006fd73b1d OR " .
31                         "dfpost:6e006fd73b1 OR " .
32                         "dfpost:6e006fd73b OR " .
33                         "dfpost:6e006fd73\n",
34                 '3-byte chop');
35
36         lei_ok(qw(p2q t/data/message_embed.eml --want=dfb));
37         like($lei_out, qr/\bdfb:\S+/, 'got dfb off /dev/null file');
38 });
39 done_testing;