diff options
Diffstat (limited to 't')
-rw-r--r-- | t/lei-q-kw.t | 33 | ||||
-rw-r--r-- | t/lei.t | 3 | ||||
-rw-r--r-- | t/lei_store.t | 10 |
3 files changed, 44 insertions, 2 deletions
diff --git a/t/lei-q-kw.t b/t/lei-q-kw.t new file mode 100644 index 00000000..97b2e08f --- /dev/null +++ b/t/lei-q-kw.t @@ -0,0 +1,33 @@ +#!perl -w +# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> +use strict; use v5.10.1; use PublicInbox::TestCommon; +test_lei(sub { +lei_ok(qw(import -F eml t/plack-qp.eml)); +my $o = "$ENV{HOME}/dst"; +lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com)); +my @fn = glob("$o/cur/*:2,"); +scalar(@fn) == 1 or BAIL_OUT "wrote multiple or zero files: ".explain(\@fn); +rename($fn[0], "$fn[0]S") or BAIL_OUT "rename $!"; + +lei_ok(qw(q -o), "maildir:$o", qw(m:bogus-noresults@example.com)); +ok(!glob("$o/cur/*"), 'last result cleared after augment-import'); + +lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com)); +@fn = glob("$o/cur/*:2,S"); +is(scalar(@fn), 1, "`seen' flag set on Maildir file"); + +# ensure --no-import-augment works +my $n = $fn[0]; +$n =~ s/,S\z/,RS/; +rename($fn[0], $n) or BAIL_OUT "rename $!"; +lei_ok(qw(q --no-import-augment -o), "maildir:$o", + qw(m:bogus-noresults@example.com)); +ok(!glob("$o/cur/*"), '--no-import-augment cleared destination'); +lei_ok(qw(q -o), "maildir:$o", qw(m:qp@example.com)); +@fn = glob("$o/cur/*:2,S"); +is(scalar(@fn), 1, "`seen' flag (but not `replied') set on Maildir file"); + +# TODO: other destination types +}); +done_testing; @@ -138,7 +138,8 @@ SKIP: { lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m)); is($? >> 8, 3, 'got curl exit for bogus URL'); lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m -o), "$home/junk"); - is($? >> 8, 3, 'got curl exit for bogus URL with Maildir'); + is($? >> 8, 3, 'got curl exit for bogus URL with Maildir') or + diag $lei_err; is($lei_out, '', 'no output'); }; # /SKIP }; diff --git a/t/lei_store.t b/t/lei_store.t index e93fe779..1c3f7841 100644 --- a/t/lei_store.t +++ b/t/lei_store.t @@ -124,8 +124,16 @@ SKIP: { $ids = $sto->ipc_do('set_eml', $eml, qw(seen answered)); is_deeply($ids, [ $no_mid->{num} ], 'docid returned w/o mid w/o ipc'); $wait = $sto->ipc_do('done'); - @kw = $sto->search->msg_keywords($no_mid->{num}); + + my $lse = $sto->search; + @kw = $lse->msg_keywords($no_mid->{num}); is_deeply(\@kw, [qw(answered seen)], 'set changed kw w/o ipc'); + is($lse->kw_changed($eml, [qw(answered seen)]), 0, + 'kw_changed false when unchanged'); + is($lse->kw_changed($eml, [qw(answered seen flagged)]), 1, + 'kw_changed true when +flagged'); + is($lse->kw_changed(eml_load('t/plack-qp.eml'), ['seen']), undef, + 'kw_changed undef on unknown message'); } done_testing; |