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 -imapd Mail::IMAPClient));
8 my ($tmpdir, $for_destroy) = tmpdir;
9 my $expect = eml_load('t/data/0001.patch');
10 test_lei({ tmpdir => $tmpdir }, sub {
11 my $home = $ENV{HOME};
13 make_path("$md/new", "$md/cur", "$md/tmp");
14 cp('t/data/0001.patch', "$md/new/y") or xbail "cp $md $!";
15 cp('t/data/message_embed.eml', "$md/cur/x:2,S") or xbail "cp $md $!";
16 lei_ok qw(index -q), $md;
17 lei_ok qw(tag t/data/0001.patch +kw:seen);
18 lei_ok qw(export-kw --all=local);
19 ok(!-e "$md/new/y", 'original gone');
20 is_deeply(eml_load("$md/cur/y:2,S"), $expect,
21 "`seen' kw exported");
23 lei_ok qw(tag t/data/0001.patch +kw:answered);
24 lei_ok qw(export-kw --all=local);
25 ok(!-e "$md/cur/y:2,S", 'seen-only file gone');
26 is_deeply(eml_load("$md/cur/y:2,RS"), $expect, "`R' added");
28 lei_ok qw(tag t/data/0001.patch -kw:answered -kw:seen);
29 lei_ok qw(export-kw --mode=set --all=local);
30 ok(!-e "$md/cur/y:2,RS", 'seen+answered file gone');
31 is_deeply(eml_load("$md/cur/y:2,"), $expect, 'no keywords left');