X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fwww_listing.t;h=6166b94ed508ab5c642c38d204eb5685d47132de;hb=d3c6f8e57b15e8d3de0431c8419bdd0497ec3d32;hp=546c2f8fab0cc18a8f98620c04feb9819f74a205;hpb=279a47f3f64fc7a414247922b870e58a0b334b0f;p=public-inbox.git
diff --git a/t/www_listing.t b/t/www_listing.t
index 546c2f8f..6166b94e 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -1,158 +1,262 @@
-# Copyright (C) 2019 all contributors
+#!perl -w
+# Copyright (C) all contributors
# License: AGPL-3.0+
# manifest.js.gz generation and grok-pull integration test
-use strict;
-use warnings;
-use Test::More;
-use PublicInbox::Spawn qw(which);
-use File::Temp qw/tempdir/;
-require './t/common.perl';
-my @mods = qw(URI::Escape Plack::Builder IPC::Run Digest::SHA HTTP::Tiny
- IO::Compress::Gzip IO::Uncompress::Gunzip Net::HTTP);
-foreach my $mod (@mods) {
- eval("require $mod") or plan skip_all => "$mod missing for $0";
-}
-use_ok 'PublicInbox::WwwListing';
+use strict; use v5.10.1; use PublicInbox::TestCommon;
+use PublicInbox::Import;
+use IO::Uncompress::Gunzip qw(gunzip);
+require_mods(qw(json URI::Escape Plack::Builder Digest::SHA HTTP::Tiny));
+require PublicInbox::WwwListing;
+require PublicInbox::ManifestJsGz;
+use PublicInbox::Config;
+my $json = PublicInbox::Config::json();
+
use_ok 'PublicInbox::Git';
-my $fi_data = './t/git.fast-import-data';
-my $tmpdir = tempdir('www_listing-tmp-XXXXXX', TMPDIR => 1, CLEANUP => 1);
+my ($tmpdir, $for_destroy) = tmpdir();
my $bare = PublicInbox::Git->new("$tmpdir/bare.git");
-is(system(qw(git init -q --bare), $bare->{git_dir}), 0, 'git init --bare');
-is(PublicInbox::WwwListing::fingerprint($bare), undef,
- 'empty repo has no fingerprint');
-
-my $cmd = [ 'git', "--git-dir=$bare->{git_dir}", qw(fast-import --quiet) ];
-ok(IPC::Run::run($cmd, '<', $fi_data), 'fast-import');
+PublicInbox::Import::init_bare($bare->{git_dir});
+is($bare->manifest_entry, undef, 'empty repo has no manifest entry');
+{
+ my $fi_data = './t/git.fast-import-data';
+ open my $fh, '<', $fi_data or die "open $fi_data: $!";
+ my $env = { GIT_DIR => $bare->{git_dir} };
+ is(xsys([qw(git fast-import --quiet)], $env, { 0 => $fh }), 0,
+ 'fast-import');
+}
-like(PublicInbox::WwwListing::fingerprint($bare), qr/\A[a-f0-9]{40}\z/,
+like($bare->manifest_entry->{fingerprint}, qr/\A[a-f0-9]{40}\z/,
'got fingerprint with non-empty repo');
-my $pid;
-END { kill 'TERM', $pid if defined $pid };
+sub tiny_test {
+ my ($json, $host, $port, $html) = @_;
+ my ($tmp, $res);
+ my $http = HTTP::Tiny->new;
+ if ($html) {
+ $res = $http->get("http://$host:$port/");
+ is($res->{status}, 200, 'got HTML listing');
+ like($res->{content}, qr!