X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Findex-git-times.t;h=52173396b1eaa78074d6bbd13ac1f80985d84ea6;hb=d3c6f8e57b15e8d3de0431c8419bdd0497ec3d32;hp=2e9e88e89794dd632850297ac0303c7e59838fe3;hpb=8e81d6f0d44198717ae540421a09824d75c9bb6d;p=public-inbox.git
diff --git a/t/index-git-times.t b/t/index-git-times.t
index 2e9e88e8..52173396 100644
--- a/t/index-git-times.t
+++ b/t/index-git-times.t
@@ -1,9 +1,13 @@
-# Copyright (C) 2020 all contributors
+#!perl -w
+# Copyright (C) 2020-2021 all contributors
# License: AGPL-3.0+
+use strict;
+use v5.10.1;
use Test::More;
use PublicInbox::TestCommon;
-use PublicInbox::Import;
use PublicInbox::Config;
+use PublicInbox::Admin;
+use PublicInbox::Import;
use File::Path qw(remove_tree);
require_mods(qw(DBD::SQLite Search::Xapian));
@@ -13,27 +17,28 @@ my ($tmpdir, $for_destroy) = tmpdir();
local $ENV{PI_CONFIG} = "$tmpdir/cfg";
my $v1dir = "$tmpdir/v1";
my $addr = 'x@example.com';
+my $default_branch = PublicInbox::Import::default_branch;
run_script(['-init', '--indexlevel=medium', 'v1', $v1dir,
'http://example.com/x', $addr])
or die "init failed";
{
- my $data = <<'EOF';
+ my $data = <<"EOF";
blob
mark :1
data 133
-From: timeless
-To: x
+From: timeless
+To: x
Subject: can I haz the time?
-Message-ID: <19700101000000-1234@example.com>
+Message-ID: <19700101000000-1234\@example.com>
plz
-reset refs/heads/master
-commit refs/heads/master
+reset $default_branch
+commit $default_branch
mark :2
-author timeless 749520000 +0100
-committer x 1285977600 -0100
+author timeless 749520000 +0100
+committer x 1285977600 -0100
data 20
can I haz the time?
M 100644 :1 53/256f6177504c2878d3a302ef5090dacf5e752c
@@ -44,21 +49,27 @@ EOF
print $w $data or die;
close $w or die;
my $cmd = ['git', "--git-dir=$v1dir", 'fast-import', '--quiet'];
- PublicInbox::Import::run_die($cmd, undef, { 0 => $r });
+ xsys_e($cmd, undef, { 0 => $r });
}
-run_script(['-index', $v1dir]) or die 'v1 index failed';
+run_script(['-index', '--skip-docdata', $v1dir]) or die 'v1 index failed';
+
my $smsg;
{
my $cfg = PublicInbox::Config->new;
my $ibx = $cfg->lookup($addr);
+ my $lvl = PublicInbox::Admin::detect_indexlevel($ibx);
+ is($lvl, 'medium', 'indexlevel detected');
+ is($ibx->{-skip_docdata}, 1, '--skip-docdata flag set on -index');
$smsg = $ibx->over->get_art(1);
is($smsg->{ds}, 749520000, 'datestamp from git author time');
is($smsg->{ts}, 1285977600, 'timestamp from git committer time');
- my $res = $ibx->search->query("m:$smsg->{mid}");
- is(scalar @$res, 1, 'got one result for m:');
+ my $mset = $ibx->search->mset("m:$smsg->{mid}");
+ is($mset->size, 1, 'got one result for m:');
+ my $res = $ibx->search->mset_to_smsg($ibx, $mset);
is($res->[0]->{ds}, $smsg->{ds}, 'Xapian stored datestamp');
- $res = $ibx->search->query('d:19931002..19931002');
+ $mset = $ibx->search->mset('d:19931002..19931002');
+ $res = $ibx->search->mset_to_smsg($ibx, $mset);
is(scalar @$res, 1, 'got one result for d:');
is($res->[0]->{ds}, $smsg->{ds}, 'Xapian search on datestamp');
}
@@ -70,14 +81,20 @@ SKIP: {
my $check_v2 = sub {
my $ibx = PublicInbox::Inbox->new({inboxdir => $v2dir,
address => $addr});
+ my $lvl = PublicInbox::Admin::detect_indexlevel($ibx);
+ is($lvl, 'medium', 'indexlevel detected after convert');
+ is($ibx->{-skip_docdata}, 1,
+ '--skip-docdata preserved after convert');
my $v2smsg = $ibx->over->get_art(1);
is($v2smsg->{ds}, $smsg->{ds},
'v2 datestamp from git author time');
is($v2smsg->{ts}, $smsg->{ts},
'v2 timestamp from git committer time');
- my $res = $ibx->search->query("m:$smsg->{mid}");
+ my $mset = $ibx->search->mset("m:$smsg->{mid}");
+ my $res = $ibx->search->mset_to_smsg($ibx, $mset);
is($res->[0]->{ds}, $smsg->{ds}, 'Xapian stored datestamp');
- $res = $ibx->search->query('d:19931002..19931002');
+ $mset = $ibx->search->mset('d:19931002..19931002');
+ $res = $ibx->search->mset_to_smsg($ibx, $mset);
is(scalar @$res, 1, 'got one result for d:');
is($res->[0]->{ds}, $smsg->{ds}, 'Xapian search on datestamp');
};