X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fwww_listing.t;h=c556a2d72aeb1c8d887c93103e2828141949e872;hb=5ca29b7f2789517f0a41f1482509f504b8b601e1;hp=e1263360c68f1d21d2ad325dfbaa6bc033881e9a;hpb=684d26cecc0891261783be179909b0e434692b25;p=public-inbox.git
diff --git a/t/www_listing.t b/t/www_listing.t
index e1263360..c556a2d7 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -1,50 +1,57 @@
-# Copyright (C) 2019 all contributors
+#!perl -w
+# Copyright (C) 2019-2021 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);
-require './t/common.perl';
-my @mods = qw(URI::Escape Plack::Builder Digest::SHA
- IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny);
-foreach my $mod (@mods) {
- eval("require $mod") or plan skip_all => "$mod missing for $0";
-}
-
+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;
-my $json = eval { PublicInbox::WwwListing::_json() };
-plan skip_all => "JSON module missing: $@" if $@;
+require PublicInbox::ManifestJsGz;
+use PublicInbox::Config;
+my $json = PublicInbox::Config::json();
use_ok 'PublicInbox::Git';
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');
+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';
- local $ENV{GIT_DIR} = $bare->{git_dir};
- is(system("git fast-import --quiet <$fi_data"), 0, 'fast-import');
+ 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');
sub tiny_test {
- my ($json, $host, $port) = @_;
+ my ($json, $host, $port, $html) = @_;
+ my ($tmp, $res);
my $http = HTTP::Tiny->new;
- my $res = $http->get("http://$host:$port/manifest.js.gz");
+ if ($html) {
+ $res = $http->get("http://$host:$port/");
+ is($res->{status}, 200, 'got HTML listing');
+ like($res->{content}, qr!