1 # Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use File::Temp qw/tempdir/;
8 my $tmpdir = tempdir('psgi-text-XXXXXX', TMPDIR => 1, CLEANUP => 1);
9 my $maindir = "$tmpdir/main.git";
10 my $addr = 'test-public@example.com';
11 my $cfgpfx = "publicinbox.test";
12 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape);
13 foreach my $mod (@mods) {
15 plan skip_all => "$mod missing for psgi_text.t" if $@;
17 use_ok $_ foreach @mods;
18 use PublicInbox::Import;
20 use PublicInbox::Config;
22 use_ok 'PublicInbox::WwwText';
24 my $config = PublicInbox::Config->new(\<<EOF);
26 $cfgpfx.inboxdir=$maindir
28 is(0, system(qw(git init -q --bare), $maindir), "git init (main)");
29 my $www = PublicInbox::WWW->new($config);
31 test_psgi(sub { $www->call(@_) }, sub {
34 $res = $cb->(GET('/test/_/text/help/'));
35 like($res->content, qr!<title>public-inbox help.*</title>!,
37 $res = $cb->(GET('/test/_/text/config/raw'));
38 my $f = "$tmpdir/cfg";
39 open my $fh, '>', $f or die;
40 print $fh $res->content or die;
42 my $cfg = PublicInbox::Config->new($f);
43 is($cfg->{"$cfgpfx.address"}, $addr, 'got expected address in config');