Commit 6e4f3acb authored by Kevin Atkinson's avatar Kevin Atkinson

Enhance tests for files API root best-effort pin.

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent 685cd28d
...@@ -11,13 +11,15 @@ test_description="test how the unix files api interacts with the gc" ...@@ -11,13 +11,15 @@ test_description="test how the unix files api interacts with the gc"
test_init_ipfs test_init_ipfs
test_expect_success "object not removed after gc" ' test_expect_success "object not removed after gc" '
echo "hello world" | ipfs files write --create /hello.txt && echo "hello world" > hello.txt &&
cat hello.txt | ipfs files write --create /hello.txt &&
ipfs repo gc && ipfs repo gc &&
ipfs cat QmVib14uvPnCP73XaCDpwugRuwfTsVbGyWbatHAmLSdZUS ipfs cat QmVib14uvPnCP73XaCDpwugRuwfTsVbGyWbatHAmLSdZUS
' '
test_expect_success "/hello.txt still accessible after gc" ' test_expect_success "/hello.txt still accessible after gc" '
ipfs files read /hello.txt ipfs files read /hello.txt > hello-actual &&
test_cmp hello.txt hello-actual
' '
ADIR_HASH=QmbCgoMYVuZq8m1vK31JQx9DorwQdLMF1M3sJ7kygLLqnW ADIR_HASH=QmbCgoMYVuZq8m1vK31JQx9DorwQdLMF1M3sJ7kygLLqnW
...@@ -27,7 +29,6 @@ test_expect_success "gc okay after adding incomplete node -- prep" ' ...@@ -27,7 +29,6 @@ test_expect_success "gc okay after adding incomplete node -- prep" '
ipfs files mkdir /adir && ipfs files mkdir /adir &&
echo "file1" | ipfs files write --create /adir/file1 && echo "file1" | ipfs files write --create /adir/file1 &&
echo "file2" | ipfs files write --create /adir/file2 && echo "file2" | ipfs files write --create /adir/file2 &&
ipfs cat $FILE1_HASH &&
ipfs pin add --recursive=false $ADIR_HASH && ipfs pin add --recursive=false $ADIR_HASH &&
ipfs files rm -r /adir && ipfs files rm -r /adir &&
ipfs repo gc && # will remove /adir/file1 and /adir/file2 but not /adir ipfs repo gc && # will remove /adir/file1 and /adir/file2 but not /adir
...@@ -42,4 +43,34 @@ test_expect_success "gc okay after adding incomplete node" ' ...@@ -42,4 +43,34 @@ test_expect_success "gc okay after adding incomplete node" '
ipfs refs $ADIR_HASH ipfs refs $ADIR_HASH
' '
test_expect_success "add directory with direct pin" '
mkdir mydir/ &&
echo "hello world!" > mydir/hello.txt &&
FILE_UNPINNED=$(ipfs add --pin=false -q -r mydir/hello.txt) &&
DIR_PINNED=$(ipfs add --pin=false -q -r mydir | tail -n1) &&
ipfs add --pin=false -r mydir &&
ipfs pin add --recursive=false $DIR_PINNED &&
ipfs cat $FILE_UNPINNED
'
test_expect_success "run gc and make sure directory contents are removed" '
ipfs repo gc &&
test_must_fail ipfs cat $FILE_UNPINNED
'
test_expect_success "add incomplete directory and make sure gc is okay" '
ipfs files cp /ipfs/$DIR_PINNED /mydir &&
ipfs repo gc &&
test_must_fail ipfs cat $FILE_UNPINNED
'
test_expect_success "add back directory contents and run gc" '
ipfs add --pin=false mydir/hello.txt &&
ipfs repo gc
'
test_expect_success "make sure directory contents are not removed" '
ipfs cat $FILE_UNPINNED
'
test_done test_done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment