X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei_store.t;h=5a5e5de03e16452467c07d44528dca1dacc516b3;hb=115d59641bda19405a3ed82dc72e129f9196fad5;hp=258db25a8171f7d9a6a7c7b550fe3f781238cb55;hpb=327a4c0a44ab301922a2b2829d423d2e9fc18faf;p=public-inbox.git
diff --git a/t/lei_store.t b/t/lei_store.t
index 258db25a..5a5e5de0 100644
--- a/t/lei_store.t
+++ b/t/lei_store.t
@@ -1,5 +1,5 @@
#!perl -w
-# Copyright (C) 2020-2021 all contributors
+# Copyright (C) all contributors
# License: AGPL-3.0+
use strict;
use v5.10.1;
@@ -21,14 +21,9 @@ like($smsg->{blob}, qr/\A[0-9a-f]+\z/, 'add returned OID');
my $eml = eml_load('t/data/0001.patch');
is($sto->add_eml($eml), undef, 'idempotent');
$sto->done;
-is_deeply([$sto->maildir_keywords('/foo:2,')], [], 'Maildir no keywords');
-is_deeply([$sto->maildir_keywords('/foo:2,S')], ['seen'], 'Maildir seen');
-is_deeply([$sto->maildir_keywords('/foo:2,RS')], ['answered', 'seen'],
- 'Maildir answered + seen');
-is_deeply([$sto->maildir_keywords('/foo:2,RSZ')], ['answered', 'seen'],
- 'Maildir answered + seen w/o Z');
{
my $es = $sto->search;
+ ok($es->can('isrch'), ref($es). ' can ->isrch (for SolverGit)');
my $msgs = $es->over->query_xover(0, 1000);
is(scalar(@$msgs), 1, 'one message');
is($msgs->[0]->{blob}, $smsg->{blob}, 'blob matches');
@@ -36,43 +31,44 @@ is_deeply([$sto->maildir_keywords('/foo:2,RSZ')], ['answered', 'seen'],
is($mset->size, 1, 'search works');
is_deeply($es->mset_to_artnums($mset), [ $msgs->[0]->{num} ],
'mset_to_artnums');
- my @kw = $es->msg_keywords(($mset->items)[0]);
+ my $mi = ($mset->items)[0];
+ my @kw = PublicInbox::Search::xap_terms('K', $mi->get_document);
is_deeply(\@kw, [], 'no flags');
}
for my $parallel (0, 1) {
$sto->{priv_eidx}->{parallel} = $parallel;
- my $docids = $sto->set_eml_keywords($eml, qw(seen draft));
+ my $docids = $sto->set_eml_vmd($eml, { kw => [ qw(seen draft) ] });
is(scalar @$docids, 1, 'set keywords on one doc');
$sto->done;
my @kw = $sto->search->msg_keywords($docids->[0]);
is_deeply(\@kw, [qw(draft seen)], 'kw matches');
- $docids = $sto->add_eml_keywords($eml, qw(seen draft));
+ $docids = $sto->add_eml_vmd($eml, {kw => [qw(seen draft)]});
$sto->done;
is(scalar @$docids, 1, 'idempotently added keywords to doc');
@kw = $sto->search->msg_keywords($docids->[0]);
is_deeply(\@kw, [qw(draft seen)], 'kw matches after noop');
- $docids = $sto->remove_eml_keywords($eml, qw(seen draft));
+ $docids = $sto->remove_eml_vmd($eml, {kw => [qw(seen draft)]});
is(scalar @$docids, 1, 'removed from one doc');
$sto->done;
@kw = $sto->search->msg_keywords($docids->[0]);
is_deeply(\@kw, [], 'kw matches after remove');
- $docids = $sto->remove_eml_keywords($eml, qw(answered));
+ $docids = $sto->remove_eml_vmd($eml, {kw=> [qw(answered)]});
is(scalar @$docids, 1, 'removed from one doc (idempotently)');
$sto->done;
@kw = $sto->search->msg_keywords($docids->[0]);
is_deeply(\@kw, [], 'kw matches after remove (idempotent)');
- $docids = $sto->add_eml_keywords($eml, qw(answered));
+ $docids = $sto->add_eml_vmd($eml, {kw => [qw(answered)]});
is(scalar @$docids, 1, 'added to empty doc');
$sto->done;
@kw = $sto->search->msg_keywords($docids->[0]);
is_deeply(\@kw, ['answered'], 'kw matches after add');
- $docids = $sto->set_eml_keywords($eml);
+ $docids = $sto->set_eml_vmd($eml, { kw => [] });
is(scalar @$docids, 1, 'set to clobber');
$sto->done;
@kw = $sto->search->msg_keywords($docids->[0]);
@@ -80,11 +76,11 @@ for my $parallel (0, 1) {
my $set = eml_load('t/plack-qp.eml');
$set->header_set('Message-ID', "");
- my $ret = $sto->set_eml($set, 'seen');
+ my $ret = $sto->set_eml($set, { kw => [ 'seen' ] });
is(ref $ret, 'PublicInbox::Smsg', 'initial returns smsg');
- my $ids = $sto->set_eml($set, qw(seen));
+ my $ids = $sto->set_eml($set, { kw => [ 'seen' ] });
is_deeply($ids, [ $ret->{num} ], 'set_eml idempotent');
- $ids = $sto->set_eml($set, qw(seen answered));
+ $ids = $sto->set_eml($set, { kw => [ qw(seen answered) ] });
is_deeply($ids, [ $ret->{num} ], 'set_eml to change kw');
$sto->done;
@kw = $sto->search->msg_keywords($ids->[0]);
@@ -97,23 +93,23 @@ SKIP: {
$eml->header_set('Message-ID', '');
my $pid = $sto->ipc_worker_spawn('lei-store');
ok($pid > 0, 'got a worker');
- my $smsg = $sto->ipc_do('set_eml', $eml, qw(seen));
+ my $smsg = $sto->ipc_do('set_eml', $eml, { kw => [ qw(seen) ] });
is(ref($smsg), 'PublicInbox::Smsg', 'set_eml works over ipc');
- my $ids = $sto->ipc_do('set_eml', $eml, qw(seen));
+ my $ids = $sto->ipc_do('set_eml', $eml, { kw => [ qw(seen) ] });
is_deeply($ids, [ $smsg->{num} ], 'docid returned');
$eml->header_set('Message-ID');
- my $no_mid = $sto->ipc_do('set_eml', $eml, qw(seen));
+ my $no_mid = $sto->ipc_do('set_eml', $eml, { kw => [ qw(seen) ] });
my $wait = $sto->ipc_do('done');
my @kw = $sto->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 = $sto->ipc_do('set_eml', $eml, qw(seen));
+ $ids = $sto->ipc_do('set_eml', $eml, { kw => [ qw(seen) ] });
is_deeply($ids, [ $no_mid->{num} ], 'docid returned w/o mid w/ ipc');
$sto->ipc_do('done');
$sto->ipc_worker_stop;
- $ids = $sto->ipc_do('set_eml', $eml, qw(seen answered));
+ $ids = $sto->ipc_do('set_eml', $eml, { kw => [ qw(seen answered) ] });
is_deeply($ids, [ $no_mid->{num} ], 'docid returned w/o mid w/o ipc');
$wait = $sto->ipc_do('done');
@@ -128,4 +124,32 @@ SKIP: {
'kw_changed undef on unknown message');
}
+SKIP: {
+ require_mods(qw(HTTP::Date), 1);
+ my $now = HTTP::Date::time2str(time);
+ $now =~ s/GMT/+0000/ or xbail "no GMT in $now";
+ my $eml = PublicInbox::Eml->new(<<"EOM");
+Received: (listserv\@example.com) by example.com via listexpand
+ id abcde (ORCPT );
+ $now;
+Date: $now
+Subject: timezone-dependent test
+
+WHAT IS TIME ANYMORE?
+EOM
+
+ my $smsg = $sto->add_eml($eml);
+ ok($smsg && $smsg->{blob}, 'recently received message');
+ $sto->done;
+ local $ENV{TZ} = 'GMT+5';
+ my $lse = $sto->search;
+ my $qstr = 'rt:1.hour.ago.. s:timezone';
+ $lse->query_approxidate($lse->git, $qstr);
+ my $mset = $lse->mset($qstr);
+ is($mset->size, 1, 'rt:1.hour.ago.. works w/ local time');
+}
+
+is_deeply([glob("$store_dir/local/*.git/info/refs")], [],
+ 'no info/refs in private lei/store');
+
done_testing;