Skip to content

Commit

Permalink
Filestore: Expand tests.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
  • Loading branch information
kevina committed May 23, 2016
1 parent c41a47e commit f7fcefd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
43 changes: 43 additions & 0 deletions test/sharness/lib/test-filestore-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,49 @@ test_add_cat_file() {
'
}

test_post_add() {
cmd=$1
dir=$2

test_expect_success "fail after file move" '
mv mountdir/hello.txt mountdir/hello2.txt
test_must_fail ipfs cat "$HASH" >/dev/null
'

test_expect_success "okay again after moving back" '
mv mountdir/hello2.txt mountdir/hello.txt &&
ipfs cat "$HASH" >/dev/null
'

test_expect_success "fail after file move" '
mv mountdir/hello.txt mountdir/hello2.txt
test_must_fail ipfs cat "$HASH" >/dev/null
'

test_expect_success "okay after re-adding under new name" '
ipfs $cmd "$dir"/mountdir/hello2.txt 2> add.output &&
ipfs cat "$HASH" >/dev/null
'

test_expect_success "restore state" '
mv mountdir/hello2.txt mountdir/hello.txt &&
ipfs $cmd "$dir"/mountdir/hello.txt 2> add.output &&
ipfs cat "$HASH" >/dev/null
'

test_expect_success "fail after file change" '
# note: filesize shrinks
echo "hello world!" >mountdir/hello.txt &&
test_must_fail ipfs cat "$HASH" >cat.output
'

test_expect_success "fail after file change, same size" '
# note: filesize does not change
echo "HELLO WORLDS!" >mountdir/hello.txt &&
test_must_fail ipfs cat "$HASH" >cat.output
'
}

test_add_cat_5MB() {
cmd=$1
dir=$2
Expand Down
23 changes: 1 addition & 22 deletions test/sharness/t0260-filestore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,7 @@ test_init_ipfs

test_add_cat_file "add --no-copy" "."

test_expect_success "fail after file move" '
mv mountdir/hello.txt mountdir/hello2.txt
test_must_fail ipfs cat "$HASH" >/dev/null
'

test_expect_success "okay again after moving back" '
mv mountdir/hello2.txt mountdir/hello.txt
ipfs cat "$HASH" >/dev/null
'

test_expect_success "fail after file change" '
# note: filesize shrinks
echo "hello world!" >mountdir/hello.txt &&
test_must_fail ipfs cat "$HASH" >cat.output
'

test_expect_success "fail after file change, same size" '
# note: filesize does not change
echo "HELLO WORLDS!" >mountdir/hello.txt &&
test_must_fail ipfs cat "$HASH" >cat.output
'

test_post_add "add --no-copy" "."

test_add_cat_5MB "add --no-copy" "."

Expand Down
2 changes: 2 additions & 0 deletions test/sharness/t0261-filestore-online.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ test_launch_ipfs_daemon

test_add_cat_file "add-ss --no-copy" "`pwd`"

test_post_add "add-ss --no-copy" "`pwd`"

test_add_cat_5MB "add-ss --no-copy" "`pwd`"

cat <<EOF > add_expect
Expand Down

0 comments on commit f7fcefd

Please sign in to comment.