X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_text.t;h=833bcaba777c32638c1e816d15a58e755192e100;hb=0283273a14e1871955f6a9132f4f3f7884ec8a3f;hp=bf565f83dbd46a83813311dcf2db906600115dec;hpb=adecbd43d2eed046fe6e88a459d03567461fd84b;p=public-inbox.git diff --git a/t/psgi_text.t b/t/psgi_text.t index bf565f83..833bcaba 100644 --- a/t/psgi_text.t +++ b/t/psgi_text.t @@ -1,31 +1,27 @@ -# Copyright (C) 2016 all contributors +# Copyright (C) 2016-2020 all contributors # License: AGPL-3.0+ use strict; use warnings; use Test::More; -use Email::MIME; -use File::Temp qw/tempdir/; -my $tmpdir = tempdir('psgi-text-XXXXXX', TMPDIR => 1, CLEANUP => 1); +use PublicInbox::Eml; +use PublicInbox::TestCommon; +my ($tmpdir, $for_destroy) = tmpdir(); my $maindir = "$tmpdir/main.git"; my $addr = 'test-public@example.com'; my $cfgpfx = "publicinbox.test"; -my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape); -foreach my $mod (@mods) { - eval "require $mod"; - plan skip_all => "$mod missing for psgi_text.t" if $@; -} +my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder); +require_mods(@mods); use_ok $_ foreach @mods; use PublicInbox::Import; use PublicInbox::Git; use PublicInbox::Config; -use PublicInbox::WWW; +use_ok 'PublicInbox::WWW'; use_ok 'PublicInbox::WwwText'; -use Plack::Builder; -my $config = PublicInbox::Config->new({ - "$cfgpfx.address" => $addr, - "$cfgpfx.mainrepo" => $maindir, -}); -is(0, system(qw(git init -q --bare), $maindir), "git init (main)"); +my $config = PublicInbox::Config->new(\<new($config); test_psgi(sub { $www->call(@_) }, sub { @@ -34,6 +30,13 @@ test_psgi(sub { $www->call(@_) }, sub { $res = $cb->(GET('/test/_/text/help/')); like($res->content, qr!public-inbox help.*!, 'default help'); + $res = $cb->(GET('/test/_/text/config/raw')); + my $f = "$tmpdir/cfg"; + open my $fh, '>', $f or die; + print $fh $res->content or die; + close $fh or die; + my $cfg = PublicInbox::Config->new($f); + is($cfg->{"$cfgpfx.address"}, $addr, 'got expected address in config'); }); done_testing();