Skip to content

Commit

Permalink
Add tests for "ls --resolve-type=false".
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
  • Loading branch information
kevina committed Jan 4, 2017
1 parent 6cc0903 commit 91da308
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/sharness/t0045-ls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,63 @@ test_ls_cmd
test_ls_cmd_raw_leaves
test_kill_ipfs_daemon

#
# test for ls --resolve-type=false
#

test_expect_success "'ipfs add -r' succeeds" '
mkdir adir &&
# note not using a seed as the files need to have truly random content
random 1000 > adir/file1 &&
random 1000 > adir/file2 &&
ipfs add --pin=false -q -r adir > adir-hashes
'

test_expect_success "get hashes from add output" '
FILE=`head -1 adir-hashes` &&
DIR=`tail -1 adir-hashes` &&
test "$FILE" -a "$DIR"
'

test_expect_success "remove a file in dir" '
ipfs block rm $FILE
'

test_expect_success "'ipfs ls --resolve-type=false ' ok" '
ipfs ls --resolve-type=false $DIR > /dev/null
'

test_expect_success "'ipfs ls' fails" '
test_must_fail ipfs ls $DIR
'

test_launch_ipfs_daemon --offline

test_expect_success "'ipfs ls --resolve-type=false' ok" '
ipfs ls --resolve-type=false $DIR > /dev/null
'

test_expect_success "'ipfs ls' fails" '
test_must_fail ipfs ls $DIR
'

test_kill_ipfs_daemon

test_launch_ipfs_daemon

# now we try `ipfs ls --resolve-type=false` with the daemon online It
# should not even attempt to retrieve the file from the network. If
# it does it should eventually fail as the content is random and
# should not exist on the network, but we don't want to wait for a
# timeout so we will kill the request after a few seconds
test_expect_success "'ipfs ls --resolve-type=false' ok and does not hang" '
ipfs ls --resolve-type=false $DIR > /dev/null &
PID=$!
sleep 2
kill $PID 2> /dev/null
wait $PID
'

test_kill_ipfs_daemon

test_done

0 comments on commit 91da308

Please sign in to comment.