Skip to content

Commit

Permalink
Add test for no repo error message
Browse files Browse the repository at this point in the history
  • Loading branch information
rht committed May 26, 2015
1 parent 4e71ce3 commit eb5d46d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion repo/fsrepo/fsrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
13 changes: 13 additions & 0 deletions test/sharness/t0020-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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. 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" &&
Expand Down

0 comments on commit eb5d46d

Please sign in to comment.