Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reversible gc test #1523

Merged
merged 1 commit into from
Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,19 @@ test_str_contains() {
shift
echo "$@" | grep "$find" >/dev/null
}

disk_usage() {
# normalize du across systems
case $(uname -s) in
Linux)
DU="du -sb"
;;
FreeBSD)
DU="du -s -A -B 1"
;;
Darwin | DragonFly)
DU="du"
;;
esac
$DU "$1" | awk "{print \$1}"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can make a go-du that's the same everywhere eventually?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know that a 'go-coreutils' exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in os x, to get a gnu coreutils, brew install coreutils.

10 changes: 10 additions & 0 deletions test/sharness/t0080-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ test_expect_success "'ipfs pin rm' output looks good" '
test_cmp expected1 actual1
'

test_expect_failure "ipfs repo gc fully reverse ipfs add" '
random 100000 41 >gcfile &&
disk_usage "$IPFS_PATH/blocks" >expected &&
hash=`ipfs add -q gcfile` &&
ipfs pin rm -r $hash &&
ipfs repo gc &&
disk_usage "$IPFS_PATH/blocks" >actual &&
test_cmp expected actual
'

test_expect_success "file no longer pinned" '
# we expect the welcome files and gw assets to show up here
echo "$HASH_WELCOME_DOCS" >expected2 &&
Expand Down