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