Skip to content

Commit

Permalink
Add test that removes a combination of pinned, valid, and invalid blo…
Browse files Browse the repository at this point in the history
…cks.

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
  • Loading branch information
kevina committed Aug 16, 2016
1 parent bf7c5b3 commit 9ae24c3
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/sharness/t0050-block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ test_description="Test block command"

test_init_ipfs

HASH="QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk"

test_expect_success "'ipfs block put' succeeds" '
echo "Hello Mars!" >expected_in &&
ipfs block put <expected_in >actual_out
'

test_expect_success "'ipfs block put' output looks good" '
HASH="QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk" &&
echo "$HASH" >expected_out &&
test_cmp expected_out actual_out
'
Expand Down Expand Up @@ -96,6 +97,38 @@ test_expect_success "multi-block 'ipfs block rm' output looks good" '
grep -F -q "removed $FILE3HASH" actual_rm
'

test_expect_success "'add some blocks' succeeds" '
echo "Hello Mars!" | ipfs block put &&
echo "Hello Venus!" | ipfs block put
'

test_expect_success "add and pin directory" '
ipfs add -r adir
ipfs pin add -r $DIRHASH
'

HASH=QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk
HASH2=QmdnpnsaEj69isdw5sNzp3h3HkaDz7xKq7BmvFFBzNr5e7
RANDOMHASH=QRmKqGMAM6EbngbZjSqrvYzq5Qd8b1bSWymjSUY9zQSNDq

test_expect_success "multi-block 'ipfs block rm' mixed" '
test_must_fail ipfs block rm $FILE1HASH $DIRHASH $HASH $FILE3HASH $RANDOMHASH $HASH2 2> block_rm_err
'

test_expect_success "pinned block not removed" '
ipfs block stat $FILE1HASH &&
ipfs block stat $FILE3HASH
'

test_expect_success "non-pinned blocks removed" '
test_must_fail ipfs block stat $HASH &&
test_must_fail ipfs block stat $HASH2
'

test_expect_success "error reportted on removing non-existent block" '
grep -q "cannot remove $RANDOMHASH" block_rm_err
'

test_expect_success "'ipfs block stat' with nothing from stdin doesnt crash" '
test_expect_code 1 ipfs block stat < /dev/null 2> stat_out
'
Expand Down

0 comments on commit 9ae24c3

Please sign in to comment.