user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 06/12] lei blob: some extra tests
Date: Sun, 28 Mar 2021 09:01:18 +0000	[thread overview]
Message-ID: <20210328090124.3541-7-e@80x24.org> (raw)
In-Reply-To: <20210328090124.3541-1-e@80x24.org>

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';

  parent reply	other threads:[~2021-03-28  9:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-28  9:01 [PATCH 00/12] lei blob and some yak-shaving Eric Wong
2021-03-28  9:01 ` [PATCH 01/12] lei: simplify PktOp callers Eric Wong
2021-03-28  9:01 ` [PATCH 02/12] lei init: split out into separate file Eric Wong
2021-03-28  9:01 ` [PATCH 03/12] lei blob: dclose if already failed Eric Wong
2021-03-28  9:01 ` [PATCH 04/12] lei blob: support --no-mail switch Eric Wong
2021-03-28  9:01 ` [PATCH 05/12] lei blob: fail early if no git dirs Eric Wong
2021-03-28  9:01 ` Eric Wong [this message]
2021-03-28  9:01 ` [PATCH 07/12] lei help: show "NAME=VALUE" properly for -c Eric Wong
2021-03-28  9:01 ` [PATCH 08/12] lei blob: flesh out help text Eric Wong
2021-03-28  9:01 ` [PATCH 09/12] t/lei_store: ensure LeiSearch responds to ->isrch Eric Wong
2021-03-28  9:01 ` [PATCH 10/12] lei blob: add remote external support Eric Wong
2021-03-28  9:01 ` [PATCH 11/12] lei: drop coderepo placeholders, submodule TODO Eric Wong
2021-03-28  9:31   ` Eric Wong
2021-03-28  9:01 ` [PATCH 12/12] treewide: shorten temporary filename Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210328090124.3541-7-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --subject='Re: [PATCH 06/12] lei blob: some extra tests' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git