From 68b310207929db23667ca5d454a78af9d65589f2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 4 Feb 2017 02:20:35 +0000 Subject: repobrowse: start wiring up git search Much more work on this will be needed, but at least explicit flush points prevents OOMs on my system. --- t/repo_git_search_idx.t | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 t/repo_git_search_idx.t (limited to 't') diff --git a/t/repo_git_search_idx.t b/t/repo_git_search_idx.t new file mode 100644 index 00000000..934a4e6f --- /dev/null +++ b/t/repo_git_search_idx.t @@ -0,0 +1,28 @@ +# Copyright (C) 2017 all contributors +# License: AGPL-3.0+ +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(); -- cgit v1.2.3-24-ge0c7