]> Sergey Matveev's repositories - public-inbox.git/blob - t/lei-q-kw.t
lei q: import flags when clobbering/augmenting Maildirs
[public-inbox.git] / t / lei-q-kw.t
1 #!perl -w
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;
5 test_lei(sub {
6 lei_ok(qw(import -F eml t/plack-qp.eml));
7 my $o = "$ENV{HOME}/dst";
8 lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com));
9 my @fn = glob("$o/cur/*:2,");
10 scalar(@fn) == 1 or BAIL_OUT "wrote multiple or zero files: ".explain(\@fn);
11 rename($fn[0], "$fn[0]S") or BAIL_OUT "rename $!";
12
13 lei_ok(qw(q -o), "maildir:$o", qw(m:bogus-noresults@example.com));
14 ok(!glob("$o/cur/*"), 'last result cleared after augment-import');
15
16 lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com));
17 @fn = glob("$o/cur/*:2,S");
18 is(scalar(@fn), 1, "`seen' flag set on Maildir file");
19
20 # ensure --no-import-augment works
21 my $n = $fn[0];
22 $n =~ s/,S\z/,RS/;
23 rename($fn[0], $n) or BAIL_OUT "rename $!";
24 lei_ok(qw(q --no-import-augment -o), "maildir:$o",
25         qw(m:bogus-noresults@example.com));
26 ok(!glob("$o/cur/*"), '--no-import-augment cleared destination');
27 lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com));
28 @fn = glob("$o/cur/*:2,S");
29 is(scalar(@fn), 1, "`seen' flag (but not `replied') set on Maildir file");
30
31 # TODO: other destination types
32 });
33 done_testing;