@cryptotaxi247 / kubo / commits / 17d71c49c

Add test for no repo error message

rht committed May 26, 2015 at 16:23 UTC 17d71c49ceea95e2b8eb5958c4624079eb4b186a
2 files changed +15 -2
repo/fsrepo/fsrepo.go
+1 -1
@@ -52,7 +52,7 @@ type NoRepoError struct {
52 var _ error = NoRepoError{}
53
54 func (err NoRepoError) Error() string {
55 - return fmt.Sprintf("no ipfs repo found in '%s'. please run: ipfs init ", err.Path)
55 + return fmt.Sprintf("no ipfs repo found in %s. please run: ipfs init", err.Path)
56 }
57
58 const (
test/sharness/t0020-init.sh
+14 -1
@@ -21,9 +21,22 @@ test_expect_success "ipfs init fails" '
21
22 test_expect_success "ipfs init output looks good" '
23 echo "Error: failed to take lock at $IPFS_PATH: permission denied" > init_fail_exp &&
24 - test_cmp init_fail_out init_fail_exp
24 + test_cmp init_fail_exp init_fail_out
25 '
26
27 +# test no repo error message
28 +# this applies to `ipfs add sth`, `ipfs refs <hash>`
29 +test_expect_success "ipfs cat fails" '
30 + export IPFS_PATH="$(pwd)/.ipfs" &&
31 + test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out
32 +'
33 +
34 +test_expect_success "ipfs cat no repo message looks good" '
35 + echo "Error: no ipfs repo found in $IPFS_PATH. please run: ipfs init" > cat_fail_exp &&
36 + test_cmp cat_fail_exp cat_fail_out
37 +'
38 +
39 +# test that init succeeds
40 test_expect_success "ipfs init succeeds" '
41 export IPFS_PATH="$(pwd)/.ipfs" &&
42 BITS="2048" &&