diff options
author | Eric Wong <e@80x24.org> | 2021-01-02 12:12:06 -1400 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-03 18:30:26 +0000 |
commit | f87d3c32bace1552ab7f3a0437e5d6628d0ab5c5 (patch) | |
tree | d0ba496702cdeb71c4f8c7d007bea2cb73fdbf75 /t/gcf2_client.t | |
parent | 8ee251fcd420533c7b69f40c18f3536bcc30abaf (diff) | |
download | public-inbox-f87d3c32bace1552ab7f3a0437e5d6628d0ab5c5.tar.gz |
While Gcf2Client is designed to mimic what git-cat-file writes to stdout, its request format is different to support requests with a git repository path included. We'll highlight the distinction and make the GitAsyncCat support code easier-to-follow as a result. Since Gcf2Client relies on DS, we can rely on DS-specific code here, too, and use a single Unix socket instead of separate input and output pipes, reducing memory overhead in both users and kernel space. Due to the interactive nature of requests and responses, the buffer size limitations of Unix sockets on Linux seems inconsequential here (just like it is for existing "git cat-file --batch" use).
Diffstat (limited to 't/gcf2_client.t')
-rw-r--r-- | t/gcf2_client.t | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/t/gcf2_client.t b/t/gcf2_client.t index bae94c77..6d059cad 100644 --- a/t/gcf2_client.t +++ b/t/gcf2_client.t @@ -28,7 +28,7 @@ my $err_f = "$tmpdir/err"; PublicInbox::DS->Reset; open my $err, '>>', $err_f or BAIL_OUT $!; my $gcf2c = PublicInbox::Gcf2Client::new({ 2 => $err }); - $gcf2c->cat_async("$tree $git_a", sub { + $gcf2c->gcf2_async(\"$tree $git_a\n", sub { my ($bref, $oid, $type, $size, $arg) = @_; is($oid, $tree, 'got expected OID'); is($size, 30, 'got expected length'); @@ -44,7 +44,7 @@ my $err_f = "$tmpdir/err"; is($estr, '', 'nothing in stderr'); my $trunc = substr($tree, 0, 39); - $gcf2c->cat_async("$trunc $git_a", sub { + $gcf2c->gcf2_async(\"$trunc $git_a\n", sub { my ($bref, $oid, $type, $size, $arg) = @_; is(undef, $bref, 'missing bref is undef'); is($oid, $trunc, 'truncated OID printed'); @@ -63,7 +63,7 @@ my $err_f = "$tmpdir/err"; PublicInbox::DS->Reset; open $err, '>', $err_f or BAIL_OUT $!; $gcf2c = PublicInbox::Gcf2Client::new({ 2 => $err }); - $gcf2c->cat_async("$tree $git_b", sub { + $gcf2c->gcf2_async(\"$tree $git_b\n", sub { my ($bref, $oid, $type, $size, $arg) = @_; is(undef, $bref, 'missing bref from alt is undef'); $called++; @@ -78,7 +78,7 @@ my $err_f = "$tmpdir/err"; print $alt "$git_a/objects\n" or BAIL_OUT $!; close $alt or BAIL_OUT; my $expect = xqx(['git', "--git-dir=$git_a", qw(cat-file tree), $tree]); - $gcf2c->cat_async("$tree $git_a", sub { + $gcf2c->gcf2_async(\"$tree $git_a\n", sub { my ($bref, $oid, $type, $size, $arg) = @_; is($oid, $tree, 'oid match on alternates retry'); is($$bref, $expect, 'tree content matched'); @@ -86,5 +86,5 @@ my $err_f = "$tmpdir/err"; }); $gcf2c->cat_async_step($gcf2c->{inflight}); } -is($called, 4, 'cat_async callbacks hit'); +is($called, 4, 'gcf2_async callbacks hit'); done_testing; |