Skip to content

Commit

Permalink
t0030-mount.sh: improve stdout stderr fail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoroviev authored and jbenet committed Apr 1, 2015
1 parent 178a64d commit 490c885
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
19 changes: 19 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,22 @@ test_curl_resp_http_code() {
cat curl_output
return 1
}

test_must_be_empty() {
if test -s "$1"
then
echo "'$1' is not empty, it contains:"
cat "$1"
return 1
fi
}

test_should_contain() {
test "$#" = 2 || error "bug in the test script: not 2 parameters to test_should_contain"
if ! grep -q "$1" "$2"
then
echo "'$2' does not contain '$1', it contains:"
cat "$2"
return 1
fi
}
11 changes: 5 additions & 6 deletions test/sharness/t0030-mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ test_launch_ipfs_daemon

# test mount failure before mounting properly.

test_expect_success "'ipfs mount' fails when no mount dir" '
test_must_fail ipfs mount -f=not_ipfs -n=not_ipns >actual
test_expect_success "'ipfs mount' fails when there is no mount dir" '
test_must_fail ipfs mount -f=not_ipfs -n=not_ipns >output 2>output.err
'

test_expect_success "'ipfs mount' output looks good when it fails" '
! grep "IPFS mounted at: $(pwd)/ipfs" actual >/dev/null &&
! grep "IPNS mounted at: $(pwd)/ipns" actual >/dev/null ||
test_fsh cat actual
test_expect_success "'ipfs mount' output looks good" '
test_must_be_empty output &&
test_should_contain "not_ipns\|not_ipfs" output.err
'

# now mount properly, and keep going
Expand Down

0 comments on commit 490c885

Please sign in to comment.