X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_v2.t;h=e4f7306e1606b3f93abcb33471f5b817d65c72b7;hb=dde1b083571ed893cbb1990f01f9e11ed804cba5;hp=faa139fb7aa2a64ae0405d5124071ce271e995b7;hpb=fad9acd35e56a289ade90a62d056b2a6663d448c;p=public-inbox.git diff --git a/t/psgi_v2.t b/t/psgi_v2.t index faa139fb..e4f7306e 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -1,8 +1,10 @@ -# Copyright (C) 2018 all contributors +# Copyright (C) 2018-2019 all contributors # License: AGPL-3.0+ use strict; use warnings; use Test::More; +require './t/common.perl'; +require_git(2.6); use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; @@ -52,11 +54,11 @@ $new_mid = $mids->[1]; $im->done; my $cfgpfx = "publicinbox.v2test"; -my $cfg = { - "$cfgpfx.address" => $ibx->{-primary_address}, - "$cfgpfx.mainrepo" => $mainrepo, -}; -my $config = PublicInbox::Config->new($cfg); +my $cfg = <{-primary_address} +$cfgpfx.mainrepo=$mainrepo +EOF +my $config = PublicInbox::Config->new(\$cfg); my $www = PublicInbox::WWW->new($config); my ($res, $raw, @from_); test_psgi(sub { $www->call(@_) }, sub { @@ -113,6 +115,7 @@ test_psgi(sub { $www->call(@_) }, sub { like($raw, qr/^hello ghosts$/m, 'got third message'); @from_ = ($raw =~ m/^From /mg); is(scalar(@from_), 3, 'three From_ lines'); + $config->each_inbox(sub { $_[0]->search->reopen }); SKIP: { eval { require IO::Uncompress::Gunzip }; @@ -129,7 +132,6 @@ test_psgi(sub { $www->call(@_) }, sub { is(scalar(@from_), 3, 'three From_ lines in t.mbox.gz'); # search interface - $config->each_inbox(sub { $_[0]->search->reopen }); $res = $cb->(POST('/v2test/?q=m:a-mid@b&x=m')); $in = $res->content; $status = IO::Uncompress::Gunzip::gunzip(\$in => \$out); @@ -150,6 +152,13 @@ test_psgi(sub { $www->call(@_) }, sub { is(scalar(@from_), 3, 'three From_ lines in all.mbox'); }; + $res = $cb->(GET('/v2test/?q=m:a-mid@b&x=t')); + is($res->code, 200, 'success with threaded search'); + my $raw = $res->content; + ok($raw =~ s/\A.*>Results 1-3 of 3\b//s, 'got all results'); + my @over = ($raw =~ m/\d{4}-\d+-\d+\s+\d+:\d+ (.+)$/gm); + is_deeply(\@over, [ '(GET('/v2test/a-mid@b/')); $raw = $res->content; @@ -183,7 +192,7 @@ test_psgi(sub { $www->call(@_) }, sub { $res = $cb->(GET('/v2test/reuse@mid/T/')); $raw = $res->content; like($raw, qr/\b4\+ messages\b/, 'thread overview shown with /T/'); - my @over = ($raw =~ m/^\d{4}-\d+-\d+\s+\d+:\d+ (.+)$/gm); + @over = ($raw =~ m/^\d{4}-\d+-\d+\s+\d+:\d+ (.+)$/gm); is_deeply(\@over, [ 'call(@_) }, sub { $res = $cb->(GET('/v2test/0/info/refs')); is($res->code, 200, 'got info refs for dumb clones'); + $res = $cb->(GET('/v2test/0.git/info/refs')); + is($res->code, 200, 'got info refs for dumb clones w/ .git suffix'); $res = $cb->(GET('/v2test/info/refs')); - is($res->code, 404, 'unpartitioned git URL fails'); + is($res->code, 404, 'v2 git URL w/o shard fails'); # ensure conflicted attachments can be resolved foreach my $body (qw(old new)) {