public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 934a4e6f00f205b137cc8f161c6b58314162aed0 899 bytes (raw)
name: t/repo_git_search_idx.t 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
# Copyright (C) 2017 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use warnings;
use Test::More;
use File::Temp qw/tempdir/;
use_ok 'PublicInbox::RepoGitSearchIdx';
my $test = require './t/repobrowse_common_git.perl';
my $git_dir = $test->{git_dir};
my $xdir = "$git_dir/rg";
my $idx = PublicInbox::RepoGitSearchIdx->new($git_dir, $xdir);
ok($idx->xdb && -d $xdir, 'Xapian dir created');
$idx->index_sync;

my $mset = $idx->query('bs:"add header"');
my $doc;
$doc = $_->get_document foreach $mset->items;
ok($doc, 'got document');
is('cb3b92d257e628b512a2eee0861f8935c594cd12', $doc->get_data, 'DATA OK');

foreach my $q (qw(id:cb3b92d257e628b512a2eee0861f8935c594cd12 id:cb3b92d2*)) {
	$mset = $idx->query($q);
	$doc = undef;
	$doc = $_->get_document foreach $mset->items;
	ok($doc, "got document for $q");
}

done_testing();

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git