From eb5d46d89c5497c464dfbb0a51ed1834a7295050 Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 26 May 2015 16:23:21 +0700 Subject: [PATCH] Add test for no repo error message --- repo/fsrepo/fsrepo.go | 2 +- test/sharness/t0020-init.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index 446458a3740..9c47b166011 100644 --- a/repo/fsrepo/fsrepo.go +++ b/repo/fsrepo/fsrepo.go @@ -52,7 +52,7 @@ type NoRepoError struct { var _ error = NoRepoError{} func (err NoRepoError) Error() string { - return fmt.Sprintf("no ipfs repo found in '%s'. please run: ipfs init ", err.Path) + return fmt.Sprintf("no ipfs repo found in %s. please run: ipfs init", err.Path) } const ( diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index 6ca20af0aa7..e6750150f4b 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -24,6 +24,19 @@ test_expect_success "ipfs init output looks good" ' test_cmp init_fail_out init_fail_exp ' +# test no repo error message +# this applies to `ipfs add sth`, `ipfs refs ` +test_expect_success "ipfs cat fails" ' + export IPFS_PATH="$(pwd)/.ipfs" && + test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out +' + +test_expect_success "ipfs cat no repo message looks good" ' + echo "Error: no ipfs repo found in $IPFS_PATH. please run: ipfs init" > cat_fail_exp && + test_cmp cat_fail_out cat_fail_exp +' + +# test that init succeeds test_expect_success "ipfs init succeeds" ' export IPFS_PATH="$(pwd)/.ipfs" && BITS="2048" &&