about summary refs log tree commit
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-25 07:50:35 +0000
committerEric Wong <e@80x24.org>2019-12-26 10:48:19 +0000
commit5c94a55c24a17c8250cf80d78246851c0a7c4087 (patch)
tree394f9939a451083fda347430c151bef9695f697c /t
parent3647997eaf49410bbf3e33bfb3874c611ab0c38b (diff)
downloadpublic-inbox-5c94a55c24a17c8250cf80d78246851c0a7c4087.tar.gz
This allows callers to avoid allocating several KB for for every
call to ->async_cat.
Diffstat (limited to 't')
-rw-r--r--t/git.t21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/git.t b/t/git.t
index d4694f44..6cfadd08 100644
--- a/t/git.t
+++ b/t/git.t
@@ -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) {