Add reversible gc test
License: MIT Signed-off-by: rht <rhtbot@gmail.com>
rht committed
Jul 28, 2015 at 09:42 UTC
eb4508210331d796d415a187b1cf8596e768acfe
2 files changed
+26
test/sharness/lib/test-lib.sh
+16
@@ -314,3 +314,19 @@ test_str_contains() {
314
shift
315
echo "$@" | grep "$find" >/dev/null
316
}
317
+
318
+disk_usage() {
319
+ # normalize du across systems
320
+ case $(uname -s) in
321
+ Linux)
322
+ DU="du -sb"
323
+ ;;
324
+ FreeBSD)
325
+ DU="du -s -A -B 1"
326
+ ;;
327
+ Darwin | DragonFly)
328
+ DU="du"
329
+ ;;
330
+ esac
331
+ $DU "$1" | awk "{print \$1}"
332
+}
test/sharness/t0080-repo.sh
+10
@@ -44,6 +44,16 @@ test_expect_success "'ipfs pin rm' output looks good" '
44
test_cmp expected1 actual1
45
'
46
47
+test_expect_failure "ipfs repo gc fully reverse ipfs add" '
48
+ random 100000 41 >gcfile &&
49
+ disk_usage "$IPFS_PATH/blocks" >expected &&
50
+ hash=`ipfs add -q gcfile` &&
51
+ ipfs pin rm -r $hash &&
52
+ ipfs repo gc &&
53
+ disk_usage "$IPFS_PATH/blocks" >actual &&
54
+ test_cmp expected actual
55
+'
56
+
57
test_expect_success "file no longer pinned" '
58
# we expect the welcome files and gw assets to show up here
59
echo "$HASH_WELCOME_DOCS" >expected2 &&