fix(sharness): gc repo size tests failing
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Oct 15, 2018 at 09:24 UTC
a4fab7f885692c67132006aacf917d1cb5900c38
2 files changed
+12
-2
test/sharness/lib/test-lib.sh
+3
@@ -406,6 +406,9 @@ directory_size() {
406
fsize=$(file_size "$fname")
407
res=$?
408
if ! test $res -eq 0; then
409
+ if ! test -e "$fname"; then
410
+ continue;
411
+ fi
412
echo "failed to get filesize" >&2
413
return $res
414
fi
test/sharness/t0080-repo.sh
+9
-2
@@ -48,19 +48,26 @@ test_expect_success "'ipfs pin rm' output looks good" '
48
test_cmp expected1 actual1
49
'
50
51
-test_expect_success "ipfs repo gc fully reverse ipfs add" '
51
+test_expect_success "ipfs repo gc fully reverse ipfs add (part 1)" '
52
ipfs repo gc &&
53
random 100000 41 >gcfile &&
54
expected="$(directory_size "$IPFS_PATH/blocks")" &&
55
find "$IPFS_PATH/blocks" -type f &&
56
hash=$(ipfs add -q gcfile) &&
57
ipfs pin rm -r $hash &&
58
- ipfs repo gc &&
58
+ ipfs repo gc
59
+'
60
+
61
+test_kill_ipfs_daemon
62
+
63
+test_expect_success "ipfs repo gc fully reverse ipfs add (part 2)" '
64
actual=$(directory_size "$IPFS_PATH/blocks") &&
65
{ test "$actual" -eq "$expected" || test_fsh echo "$actual != $expected"; } &&
66
{ test "$actual" -gt "0" || test_fsh echo "not($actual > 0)"; }
67
'
68
69
+test_launch_ipfs_daemon --offline
70
+
71
test_expect_success "file no longer pinned" '
72
ipfs pin ls --type=recursive --quiet >actual2 &&
73
test_expect_code 1 grep $HASH actual2