From 91da3088d31a2b2bf3dd92b9d932d37ff6fbb17f Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Tue, 3 Jan 2017 21:19:45 -0500 Subject: [PATCH] Add tests for "ls --resolve-type=false". License: MIT Signed-off-by: Kevin Atkinson --- test/sharness/t0045-ls.sh | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/test/sharness/t0045-ls.sh b/test/sharness/t0045-ls.sh index 8952486a579..e17a4652857 100755 --- a/test/sharness/t0045-ls.sh +++ b/test/sharness/t0045-ls.sh @@ -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