# Copyright (C) 2019 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 PublicInbox::TestCommon;
require_mods(qw(URI::Escape Plack::Builder Digest::SHA
IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny));
require PublicInbox::WwwListing;
my $json = eval { PublicInbox::WwwListing::_json() };
plan skip_all => "JSON module missing: $@" if $@;
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');
{
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');
}
like(PublicInbox::WwwListing::fingerprint($bare), qr/\A[a-f0-9]{40}\z/,
'got fingerprint with non-empty repo');
sub tiny_test {
my ($json, $host, $port) = @_;
my $http = HTTP::Tiny->new;
my $res = $http->get("http://$host:$port/");
is($res->{status}, 200, 'got HTML listing');
like($res->{content}, qr!