Skip to content

Commit

Permalink
test the ipfs cat --length flag
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Steven Allen <[email protected]>
  • Loading branch information
Stebalien committed Jan 6, 2018
1 parent 153bb68 commit 089496b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/sharness/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,56 @@ test_add_cat_file() {
test_expect_code 1 ipfs cat --offset -102 "$HASH" > actual
'

test_expect_success "ipfs cat with length succeeds" '
ipfs cat --length 8 "$HASH" >actual
'

test_expect_success "ipfs cat with length output looks good" '
echo -n "Hello Wo" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat multiple hashes with offset and length succeeds" '
ipfs cat --offset 5 --length 15 "$HASH" "$HASH" "$HASH" >actual
'

test_expect_success "ipfs cat multiple hashes with offset and length looks good" '
echo " Worlds!" >expected &&
echo -n "Hello " >>expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat with exact length succeeds" '
ipfs cat --length $(ipfs cat "$HASH" | wc -c) "$HASH" >actual
'

test_expect_success "ipfs cat with exact length looks good" '
echo "Hello Worlds!" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat with 0 length succeeds" '
ipfs cat --length 0 "$HASH" >actual
'

test_expect_success "ipfs cat with 0 length looks good" '
: >expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat with oversized length succeeds" '
ipfs cat --length 100 "$HASH" >actual
'

test_expect_success "ipfs cat with oversized length looks good" '
echo "Hello Worlds!" >expected &&
test_cmp expected actual
'

test_expect_success "ipfs cat with negitive length should fail" '
test_expect_code 1 ipfs cat --length -102 "$HASH" > actual
'

test_expect_success "ipfs cat /ipfs/file succeeds" '
ipfs cat /ipfs/$HASH >actual
'
Expand Down

0 comments on commit 089496b

Please sign in to comment.