diff options
author | Eric Wong <e@80x24.org> | 2023-01-01 10:54:40 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-01-01 21:25:18 +0000 |
commit | c4b882036d272cc276cbf3a0d108244893c3c8af (patch) | |
tree | fc0955f3b83c9fee93d687e0f3dfad48e2891444 | |
parent | 115d59641bda19405a3ed82dc72e129f9196fad5 (diff) | |
download | public-inbox-c4b882036d272cc276cbf3a0d108244893c3c8af.tar.gz |
We only have to generate the expected tarball and checksum once for testing both -httpd and generic PSGI. And drop the redundant length check since the SHA-256 check is sufficient. This saves 20-30ms on my system.
-rw-r--r-- | t/solver_git.t | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/t/solver_git.t b/t/solver_git.t index d8942747..82222031 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -263,6 +263,16 @@ SKIP: { cgiturl = http://example.com/binfoo EOF close $cfgfh or die; + my $exp_digest; + { + my $exp = xqx([qw(git archive --format=tar.gz + --prefix=public-inbox-1.0.0/ v1.0.0)], + { GIT_DIR => $git_dir }); + is($?, 0, 'no error from git archive'); + ok(length($exp) > 1024, 'expected archive generated'); + $exp_digest = git_sha(256, \$exp)->hexdigest; + }; + my $cfg = PublicInbox::Config->new($cfgpath); my $www = PublicInbox::WWW->new($cfg); my $client = sub { @@ -341,14 +351,11 @@ EOF is($res->header('Content-Disposition'), qq'inline; filename="$fn"', 'c-d header'); is($res->header('ETag'), qq'"$v1_0_0_rev"', 'etag header'); - my $exp = xqx([qw(git archive --format=tar.gz - --prefix=public-inbox-1.0.0/ v1.0.0)], - { GIT_DIR => $git_dir }); + my $got = $res->content; - is(length($got), length($exp), - "length matches installed `git archive' output") and - is(git_sha(1, \$got)->hexdigest, git_sha(1, \$exp)->hexdigest, + is(git_sha(256, \$got)->hexdigest, $exp_digest, "content matches installed `git archive' output"); + undef $got; $fn = 'public-inbox-1.0.2.tar.gz'; $res = $cb->(GET("/public-inbox/snapshot/$fn")); |