From a4fab7f885692c67132006aacf917d1cb5900c38 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 15 Oct 2018 09:24:24 +0100 Subject: [PATCH] fix(sharness): gc repo size tests failing License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/lib/test-lib.sh | 3 +++ test/sharness/t0080-repo.sh | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 92df63c4e..f9ebae81e 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -406,6 +406,9 @@ directory_size() { fsize=$(file_size "$fname") res=$? if ! test $res -eq 0; then + if ! test -e "$fname"; then + continue; + fi echo "failed to get filesize" >&2 return $res fi diff --git a/test/sharness/t0080-repo.sh b/test/sharness/t0080-repo.sh index 0147f4ea9..16e304217 100755 --- a/test/sharness/t0080-repo.sh +++ b/test/sharness/t0080-repo.sh @@ -48,19 +48,26 @@ test_expect_success "'ipfs pin rm' output looks good" ' test_cmp expected1 actual1 ' -test_expect_success "ipfs repo gc fully reverse ipfs add" ' +test_expect_success "ipfs repo gc fully reverse ipfs add (part 1)" ' ipfs repo gc && random 100000 41 >gcfile && expected="$(directory_size "$IPFS_PATH/blocks")" && find "$IPFS_PATH/blocks" -type f && hash=$(ipfs add -q gcfile) && ipfs pin rm -r $hash && - ipfs repo gc && + ipfs repo gc +' + +test_kill_ipfs_daemon + +test_expect_success "ipfs repo gc fully reverse ipfs add (part 2)" ' actual=$(directory_size "$IPFS_PATH/blocks") && { test "$actual" -eq "$expected" || test_fsh echo "$actual != $expected"; } && { test "$actual" -gt "0" || test_fsh echo "not($actual > 0)"; } ' +test_launch_ipfs_daemon --offline + test_expect_success "file no longer pinned" ' ipfs pin ls --type=recursive --quiet >actual2 && test_expect_code 1 grep $HASH actual2