Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #519 from ipfs/add-passing-t0020-tests
Browse files Browse the repository at this point in the history
sharness: add t0020-init.sh
  • Loading branch information
daviddias authored Dec 15, 2016
2 parents 8da5064 + 127aad8 commit c206908
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/sharness/t0020-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test init command"

. lib/test-lib.sh

# test that ipfs fails to init if IPFS_PATH isnt writeable
test_expect_success "create dir and change perms succeeds" '
export IPFS_PATH="$(pwd)/.badipfs" &&
mkdir "$IPFS_PATH" &&
chmod 000 "$IPFS_PATH"
'

test_expect_success "ipfs init fails" '
test_must_fail ipfs init 2> init_fail_out
'

# Under Windows/Cygwin the error message is different,
# so we use the STD_ERR_MSG prereq.
if test_have_prereq STD_ERR_MSG; then
init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied"
else
init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified."
fi
init_js_err_msg="Error: EACCES: permission denied, stat '$IPFS_PATH/version'"

test_expect_success "ipfs init output looks good" '
echo "$init_js_err_msg" >init_fail_exp &&
test_cmp init_fail_exp init_fail_out
'

test_expect_success "cleanup dir with bad perms" '
chmod 775 "$IPFS_PATH" &&
rmdir "$IPFS_PATH"
'

# 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_done

0 comments on commit c206908

Please sign in to comment.