]> Sergey Matveev's repositories - public-inbox.git/blob - xt/solver.t
import_vger_from_mbox: drop redundant "use" statements
[public-inbox.git] / xt / solver.t
1 #!perl -w
2 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict;
5 use Test::More;
6 use PublicInbox::TestCommon;
7 use PublicInbox::Config; # this relies on PI_CONFIG // ~/.public-inbox/config
8 my @psgi = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder);
9 require_mods(qw(DBD::SQLite Search::Xapian), @psgi);
10 use_ok($_) for @psgi;
11 use_ok 'PublicInbox::WWW';
12 my $cfg = PublicInbox::Config->new;
13 my $www = PublicInbox::WWW->new($cfg);
14 my $app = sub {
15         my $env = shift;
16         $env->{'psgi.errors'} = \*STDERR;
17         $www->call($env);
18 };
19
20 # TODO: convert these to self-contained test cases
21 my $todo = {
22         'git' => [
23                 '9e9048b02bd04d287461543d85db0bb715b89f8c'
24                         .'/s/?b=t%2Ft3420%2Fremove-ids.sed',
25                 'eebf7a8/s/?b=t%2Ftest-lib.sh',
26                 'eb580ca513/s/?b=remote-odb.c',
27                 '776fa90f7f/s/?b=contrib/git-jump/git-jump',
28                 '5cd8845/s/?b=submodule.c',
29                 '81c1164ae5/s/?b=builtin/log.c',
30                 '6aa8857a11/s/?b=protocol.c',
31                 '96f1c7f/s/', # TODO: b=contrib/completion/git-completion.bash
32                 'b76f2c0/s/?b=po/zh_CN.po',
33         ],
34 };
35
36 my ($ibx, $urls);
37 my $client = sub {
38         my ($cb) = @_;
39         for (@$urls) {
40                 my $url = "/$ibx/$_";
41                 my $res = $cb->(GET($url));
42                 is($res->code, 200, $url);
43                 next if $res->code == 200;
44                 # diag $res->content;
45                 diag "$url failed";
46         }
47 };
48
49 while (($ibx, $urls) = each %$todo) {
50         SKIP: {
51                 if (!$cfg->lookup_name($ibx)) {
52                         skip("$ibx not configured", scalar(@$urls));
53                 }
54                 test_psgi($app, $client);
55         }
56 }
57
58 done_testing();
59 1;