]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/git.t
examples/*.psgi: add examples for -httpd
[public-inbox.git] / t / git.t
diff --git a/t/git.t b/t/git.t
index cc4fc59146c73b6c6171ce2ec1791321e1c253e0..8224969d0661fb7d6707a39ae779613ca38cf5b1 100644 (file)
--- a/t/git.t
+++ b/t/git.t
@@ -1,9 +1,9 @@
-# Copyright (C) 2015-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+use PublicInbox::TestCommon;
 my ($dir, $for_destroy) = tmpdir();
 use PublicInbox::Spawn qw(popen_rd);
 
@@ -33,6 +33,27 @@ use_ok 'PublicInbox::Git';
 
        is(${$gcf->cat_file($f)}, $$raw, 'not broken after failures');
        is(${$gcf->cat_file($f)}, $$raw, 'not broken after partial read');
+
+       my $oid = $x[0];
+       my $arg = { 'foo' => 'bar' };
+       my $res = [];
+       my $missing = [];
+       $gcf->cat_async_begin;
+       $gcf->cat_async($oid, sub {
+               my ($bref, $oid_hex, $type, $size, $arg) = @_;
+               $res = [ @_ ];
+       }, $arg);
+       $gcf->cat_async('non-existent', sub {
+               my ($bref, $oid_hex, $type, $size, $arg) = @_;
+               $missing = [ @_ ];
+       }, $arg);
+       $gcf->cat_async_wait;
+       my ($bref, $oid_hex, $type, $size, $arg_res) = @$res;
+       is_deeply([$oid_hex, $type, $size], \@x, 'got expected header');
+       is($arg_res, $arg, 'arg passed to cat_async');
+       is_deeply($raw, $bref, 'blob result matches');
+       is_deeply($missing, [ undef, undef, undef, undef, $arg],
+               'non-existent blob gives expected result');
 }
 
 if (1) {
@@ -71,7 +92,7 @@ if ('alternates reloaded') {
        my @cmd = ('git', "--git-dir=$alt", qw(hash-object -w --stdin));
        is(system(qw(git init -q --bare), $alt), 0, 'create alt directory');
        open my $fh, '<', "$alt/config" or die "open failed: $!\n";
-       my $rd = popen_rd(\@cmd, {}, { 0 => fileno($fh) } );
+       my $rd = popen_rd(\@cmd, {}, { 0 => $fh } );
        close $fh or die "close failed: $!";
        chomp(my $remote = <$rd>);
        my $gcf = PublicInbox::Git->new($dir);