1 # Copyright (C) all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 use PublicInbox::TestCommon;
6 my ($tmpdir, $for_destroy) = tmpdir();
7 my $maindir = "$tmpdir/main.git";
8 my $addr = 'test-public@example.com';
9 my $cfgpfx = "publicinbox.test";
10 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape Plack::Builder);
11 require_mods(@mods, 'IO::Uncompress::Gunzip');
12 use_ok $_ foreach @mods;
13 use PublicInbox::Import;
14 use_ok 'PublicInbox::WWW';
15 use_ok 'PublicInbox::WwwText';
16 my $config = cfg_new $tmpdir, <<EOF;
21 PublicInbox::Import::init_bare($maindir);
22 my $www = PublicInbox::WWW->new($config);
24 test_psgi(sub { $www->call(@_) }, sub {
27 my $req = GET('/test/_/text/help/');
28 my $res = $cb->($req);
29 my $content = $res->content;
30 like($content, qr!<title>public-inbox help.*</title>!, 'default help');
31 $req->header('Accept-Encoding' => 'gzip');
33 is($res->header('Content-Encoding'), 'gzip', 'got gzip encoding');
34 is($res->header('Content-Type'), 'text/html; charset=UTF-8',
36 IO::Uncompress::Gunzip::gunzip(\($res->content) => \$gunzipped);
37 is($gunzipped, $content, 'gzipped content is correct');
39 $req = GET('/test/_/text/config/raw');
41 $content = $res->content;
42 my $olen = $res->header('Content-Length');
43 my $cfg = cfg_new $tmpdir, $content;
44 is($cfg->{"$cfgpfx.address"}, $addr, 'got expected address in config');
46 $req->header('Accept-Encoding' => 'gzip');
48 is($res->header('Content-Encoding'), 'gzip', 'got gzip encoding');
49 ok($res->header('Content-Length') < $olen, 'gzipped help is smaller');
50 IO::Uncompress::Gunzip::gunzip(\($res->content) => \$gunzipped);
51 is($gunzipped, $content);