From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A60CB1FB0F for ; Sun, 28 Mar 2021 09:01:25 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/12] lei blob: some extra tests Date: Sun, 28 Mar 2021 09:01:18 +0000 Message-Id: <20210328090124.3541-7-e@80x24.org> In-Reply-To: <20210328090124.3541-1-e@80x24.org> References: <20210328090124.3541-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Most of it already gets tested since most of the logic is in SolverGit, but make sure it's all wired up properly to lei. --- t/solver_git.t | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/t/solver_git.t b/t/solver_git.t index 7bf3ba21..6d4b93c7 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -29,6 +29,7 @@ my $ibx = create_inbox 'v2', version => 2, my $v1_0_0_tag = 'cb7c42b1e15577ed2215356a2bf925aef59cdd8d'; my $v1_0_0_tag_short = substr($v1_0_0_tag, 0, 16); my $expect = '69df7d565d49fbaaeb0a067910f03dc22cd52bd0'; +my $non_existent = 'ee5e32211bf62ab6531bdf39b84b6920d0b6775a'; test_lei({tmpdir => $tmpdir}, sub { lei_ok('blob', '69df7d5', '-I', $ibx->{inboxdir}); @@ -37,6 +38,25 @@ test_lei({tmpdir => $tmpdir}, sub { my $prev = $lei_out; lei_ok(qw(blob --no-mail 69df7d5 -I), $ibx->{inboxdir}); is($lei_out, $prev, '--no-mail works'); + ok(!lei(qw(blob -I), $ibx->{inboxdir}, $non_existent), + 'non-existent blob fails'); + SKIP: { + skip '/.git exists', 1 if -e '/.git'; + require PublicInbox::OnDestroy; + opendir my $dh, '.' or xbail "opendir: $!"; + my $end = PublicInbox::OnDestroy->new($$, sub { + chdir $dh or xbail "chdir: $!"; + }); + lei_ok(qw(-C / blob 69df7d5 -I), $ibx->{inboxdir}, + "--git-dir=$git_dir"); + is($lei_out, $prev, '--git-dir works'); + + ok(!lei(qw(-C / blob --no-cwd 69df7d5 -I), $ibx->{inboxdir}), + '--no-cwd works'); + + ok(!lei(qw(-C / blob -I), $ibx->{inboxdir}, $non_existent), + 'non-existent blob fails'); + } # fallbacks lei_ok('blob', $v1_0_0_tag, '-I', $ibx->{inboxdir}); @@ -163,7 +183,6 @@ EOF close $cfgfh or die; my $cfg = PublicInbox::Config->new($cfgpath); my $www = PublicInbox::WWW->new($cfg); - my $non_existent = 'ee5e32211bf62ab6531bdf39b84b6920d0b6775a'; my $client = sub { my ($cb) = @_; my $mid = '20190401081523.16213-1-BOFH@YHBT.net';