diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index 446458a374062285dd65ba236ab0bf84934a0596..d35a3525c5ccd1bba27cf64e8e7bb18cdb7faeaa 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.\nplease run: ipfs init", err.Path) } const ( diff --git a/test/sharness/t0020-init.sh b/test/sharness/t0020-init.sh index 6ca20af0aa714ac11209bcfd10d50a60a57a017b..53141286f5787a663863ce5a77a2dafe726cc2cf 100755 --- a/test/sharness/t0020-init.sh +++ b/test/sharness/t0020-init.sh @@ -21,9 +21,23 @@ test_expect_success "ipfs init fails" ' test_expect_success "ipfs init output looks good" ' echo "Error: failed to take lock at $IPFS_PATH: permission denied" > init_fail_exp && - test_cmp init_fail_out init_fail_exp + test_cmp init_fail_exp init_fail_out ' +# test no repo error message +# this applies to `ipfs add sth`, `ipfs refs <hash>` +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." > cat_fail_exp && + echo "please run: ipfs init" >> cat_fail_exp && + test_cmp cat_fail_exp cat_fail_out +' + +# test that init succeeds test_expect_success "ipfs init succeeds" ' export IPFS_PATH="$(pwd)/.ipfs" && BITS="2048" &&