]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei_store.t
lei add-external: completion for existing URL basenames
[public-inbox.git] / t / lei_store.t
index bc0d66c20823401a8b8c8c61a4f6be1fd1d9c54b..c9360f8f08218f7da7c111515df7715e13780b3a 100644 (file)
@@ -1,5 +1,5 @@
 #!perl -w
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# 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;
@@ -12,6 +12,8 @@ require_ok 'PublicInbox::ExtSearch';
 my ($home, $for_destroy) = tmpdir();
 my $opt = { 1 => \(my $out = ''), 2 => \(my $err = '') };
 my $store_dir = "$home/lst";
+local $ENV{GIT_COMMITTER_EMAIL} = 'lei@example.com';
+local $ENV{GIT_COMMITTER_NAME} = 'lei user';
 my $lst = PublicInbox::LeiStore->new($store_dir, { creat => 1 });
 ok($lst, '->new');
 my $smsg = $lst->add_eml(eml_load('t/data/0001.patch'));
@@ -100,6 +102,30 @@ for my $parallel (0, 1) {
 SKIP: {
        require_mods(qw(Storable), 1);
        ok($lst->can('ipc_do'), 'ipc_do works if we have Storable');
+       $eml->header_set('Message-ID', '<ipc-test@example>');
+       my $pid = $lst->ipc_worker_spawn('lei-store');
+       ok($pid > 0, 'got a worker');
+       my $smsg = $lst->ipc_do('set_eml', $eml, qw(seen));
+       is(ref($smsg), 'PublicInbox::Smsg', 'set_eml works over ipc');
+       my $ids = $lst->ipc_do('set_eml', $eml, qw(seen));
+       is_deeply($ids, [ $smsg->{num} ], 'docid returned');
+
+       $eml->header_set('Message-ID');
+       my $no_mid = $lst->ipc_do('set_eml', $eml, qw(seen));
+       my $wait = $lst->ipc_do('done');
+       my @kw = $lst->search->msg_keywords($no_mid->{num});
+       is_deeply(\@kw, [qw(seen)], 'ipc set changed kw');
+
+       is(ref($smsg), 'PublicInbox::Smsg', 'no mid works ipc');
+       $ids = $lst->ipc_do('set_eml', $eml, qw(seen));
+       is_deeply($ids, [ $no_mid->{num} ], 'docid returned w/o mid w/ ipc');
+       $lst->ipc_do('done');
+       $lst->ipc_worker_stop;
+       $ids = $lst->ipc_do('set_eml', $eml, qw(seen answered));
+       is_deeply($ids, [ $no_mid->{num} ], 'docid returned w/o mid w/o ipc');
+       $wait = $lst->ipc_do('done');
+       @kw = $lst->search->msg_keywords($no_mid->{num});
+       is_deeply(\@kw, [qw(answered seen)], 'set changed kw w/o ipc');
 }
 
 done_testing;