-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
implement an ipfs cat --length flag #4553
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the
|
||
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 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that is you try this in bash on the command line this will fail as '!' has special meaning in bash when history expansion in enabled. This is disabled by default in scripts so it won't cause a problem. |
||
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 | ||
' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USE int64. THIS COULD OVERFLOW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a int64 option in go-ipfs-cmdkit, we could use a uint instead? We could also add a new option if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was really just giving @Stebalien crap, he was sitting behind me while i reviewed this and pointed out that this should be an int64