2 # Copyright (C) 2020-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;
6 ok(!$lei->(qw(import -f bogus), 't/plack-qp.eml'), 'fails with bogus format');
7 like($lei_err, qr/\bbogus unrecognized/, 'gave error message');
9 ok($lei->(qw(q s:boolean)), 'search miss before import');
10 unlike($lei_out, qr/boolean/i, 'no results, yet');
11 open my $fh, '<', 't/data/0001.patch' or BAIL_OUT $!;
12 ok($lei->([qw(import -f eml -)], undef, { %$lei_opt, 0 => $fh }),
13 'import single file from stdin') or diag $lei_err;
15 ok($lei->(qw(q s:boolean)), 'search hit after import');
16 ok($lei->(qw(import -f eml), 't/data/message_embed.eml'),
17 'import single file by path');
24 my $opt = { %$lei_opt, 0 => \$str };
25 ok($lei->([qw(import -f eml -)], undef, $opt),
26 'import single file with keywords from stdin');
28 my $res = json_utf8->decode($lei_out);
29 is($res->[1], undef, 'only one result');
30 is_deeply($res->[0]->{kw}, ['seen'], "message `seen' keyword set");
32 $str =~ tr/x/v/; # v@y
33 ok($lei->([qw(import --no-kw -f eml -)], undef, $opt),
34 'import single file with --no-kw from stdin');
36 $res = json_utf8->decode($lei_out);
37 is($res->[1], undef, 'only one result');
38 is_deeply($res->[0]->{kw}, [], 'no keywords set');
40 # see t/lei_to_mail.t for "import -f mbox*"