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;
6 use File::Path qw(make_path);
7 require_mods(qw(lei)); # see lei-import-imap.t for IMAP tests
8 my ($tmpdir, $for_destroy) = tmpdir;
9 my $expect = eml_load('t/data/0001.patch');
13 lei_ok qw(export-kw --all=local) if $do_export_kw;
15 $x =~ s!\Q$tmpdir\E/!\$TMPDIR/!;
21 ok(-f $f, "$x exists") or xbail;
24 test_lei({ tmpdir => $tmpdir }, sub {
25 my $home = $ENV{HOME};
28 make_path("$md/new", "$md/cur", "$md/tmp");
29 cp('t/data/0001.patch', "$md/new/y") or xbail "cp $md $!";
30 cp('t/data/message_embed.eml', "$md/cur/x:2,S") or xbail "cp $md $!";
31 lei_ok qw(index), $md;
32 lei_ok qw(tag t/data/0001.patch +kw:seen);
33 $wait_for->($f = "$md/cur/y:2,S");
34 ok(!-e "$md/new/y", 'original gone') or
35 diag explain([glob("$md/*/*")]);
36 is_deeply(eml_load($f), $expect, "`seen' kw exported");
38 lei_ok qw(tag t/data/0001.patch +kw:answered);
39 $wait_for->($f = "$md/cur/y:2,RS");
40 ok(!-e "$md/cur/y:2,S", 'seen-only file gone') or
41 diag explain([glob("$md/*/*")]);
42 is_deeply(eml_load($f), $expect, "`R' added");
44 lei_ok qw(tag t/data/0001.patch -kw:answered -kw:seen);
45 $wait_for->($f = "$md/cur/y:2,");
46 ok(!-e "$md/cur/y:2,RS", 'seen+answered file gone') or
47 diag explain([glob("$md/*/*")]);
48 is_deeply(eml_load($f), $expect, 'no keywords left');