add --dereference-args parameter

License: MIT
Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
This commit is contained in:
Dominic Della Valle 2018-04-23 20:22:27 -04:00 committed by Steven Allen
parent 90926ca5c7
commit 5a02b98702
2 changed files with 16 additions and 0 deletions

View File

@ -100,6 +100,7 @@ You can now check what blocks have been created by:
},
Options: []cmdkit.Option{
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
cmds.OptionDerefArgs, // a builtin option that resolves passed in filesystem links (--dereference-args)
cmdkit.BoolOption(quietOptionName, "q", "Write minimal output."),
cmdkit.BoolOption(quieterOptionName, "Q", "Write only final hash."),
cmdkit.BoolOption(silentOptionName, "Write no output."),

View File

@ -347,6 +347,19 @@ test_add_cat_raw() {
'
}
test_add_cat_derefargs() {
test_expect_success "create and hash zero length file" '
touch zero-length-file &&
ZEROHASH=$(ipfs add -q -n zero-length-file)
'
test_expect_success "create symlink and add with dereferenced arguments" '
ln -s zero-length-file symlink-to-zero &&
HASH=$(ipfs add -q -n --dereference-args symlink-to-zero) &&
test $HASH = $ZEROHASH
'
}
test_add_cat_expensive() {
ADD_FLAGS="$1"
HASH="$2"
@ -720,6 +733,8 @@ test_expect_success "ipfs add --only-hash succeeds" '
echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
'
test_add_cat_derefargs
#TODO: this doesn't work when online hence separated out from test_add_cat_file
test_expect_success "ipfs cat file fails" '
test_must_fail ipfs cat $(cat oh_hash)