# Copyright (C) 2019-2020 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;
use PublicInbox::Import;
require_mods(qw(URI::Escape Plack::Builder Digest::SHA
IO::Compress::Gzip IO::Uncompress::Gunzip HTTP::Tiny));
require PublicInbox::WwwListing;
require PublicInbox::ManifestJsGz;
my $json = do {
no warnings 'once';
$PublicInbox::ManifestJsGz::json;
} or plan skip_all => "JSON module missing";
use_ok 'PublicInbox::Git';
my ($tmpdir, $for_destroy) = tmpdir();
my $bare = PublicInbox::Git->new("$tmpdir/bare.git");
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($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 $tmp;
my $http = HTTP::Tiny->new;
my $res = $http->get("http://$host:$port/");
is($res->{status}, 200, 'got HTML listing');
like($res->{content}, qr!