]> Sergey Matveev's repositories - public-inbox.git/blob - t/lei-export-kw.t
1fe940bb6d894977edb062fda3ca03dae3bffc5e
[public-inbox.git] / t / lei-export-kw.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 use File::Copy qw(cp);
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};
12         my $md = "$home/md";
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");
22
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");
27
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');
32 });
33
34 done_testing;