提交 b7ea4bfc 作者: Kejie Zhang

modify command name and update the test

License: MIT
Signed-off-by: 's avatarKejie Zhang <601172892@qq.com>
上级 7de83f25
...@@ -37,7 +37,7 @@ const ( ...@@ -37,7 +37,7 @@ const (
progressOptionName = "progress" progressOptionName = "progress"
trickleOptionName = "trickle" trickleOptionName = "trickle"
wrapOptionName = "wrap-with-directory" wrapOptionName = "wrap-with-directory"
pathName = "name" stdinPathName = "stdin-name"
hiddenOptionName = "hidden" hiddenOptionName = "hidden"
onlyHashOptionName = "only-hash" onlyHashOptionName = "only-hash"
chunkerOptionName = "chunker" chunkerOptionName = "chunker"
...@@ -117,7 +117,7 @@ You can now check what blocks have been created by: ...@@ -117,7 +117,7 @@ You can now check what blocks have been created by:
cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."), cmdkit.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."), cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."), cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
cmdkit.StringOption(pathName, "Assign a name if the file source is stdin."), cmdkit.StringOption(stdinPathName, "Assign a name if the file source is stdin."),
cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."), cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"), cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true), cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
...@@ -183,7 +183,7 @@ You can now check what blocks have been created by: ...@@ -183,7 +183,7 @@ You can now check what blocks have been created by:
hashFunStr, _ := req.Options[hashOptionName].(string) hashFunStr, _ := req.Options[hashOptionName].(string)
inline, _ := req.Options[inlineOptionName].(bool) inline, _ := req.Options[inlineOptionName].(bool)
inlineLimit, _ := req.Options[inlineLimitOptionName].(int) inlineLimit, _ := req.Options[inlineLimitOptionName].(int)
pathName, _ := req.Options[pathName].(string) pathName, _ := req.Options[stdinPathName].(string)
// The arguments are subject to the following constraints. // The arguments are subject to the following constraints.
// //
......
...@@ -185,22 +185,22 @@ test_add_cat_file() { ...@@ -185,22 +185,22 @@ test_add_cat_file() {
test_cmp zero-length-file zero-length-file_out test_cmp zero-length-file zero-length-file_out
' '
test_expect_success "ipfs add --name" ' test_expect_success "ipfs add --stdin-name" '
NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" &&
echo "IPFS" | ipfs add --name file.txt > actual && echo "IPFS" | ipfs add --stdin-name file.txt > actual &&
echo "added $NAMEHASH file.txt" > expected && echo "added $NAMEHASH file.txt" > expected &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success "ipfs add --name -w" ' test_expect_success "ipfs add --stdin-name -w" '
NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" && NAMEHASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" &&
echo "IPFS" | ipfs add -w --name file.txt | head -n1> actual && echo "IPFS" | ipfs add -w --stdin-name file.txt | head -n1> actual &&
echo "added $NAMEHASH file.txt" > expected && echo "added $NAMEHASH file.txt" > expected &&
test_cmp expected actual test_cmp expected actual
' '
test_expect_success "ipfs cat with name" ' test_expect_success "ipfs cat with stdin-name" '
NAMEHASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) && NAMEHASH=$(echo "IPFS" | ipfs add -w --stdin-name file.txt -Q) &&
ipfs cat /ipfs/$NAMEHASH/file.txt > expected && ipfs cat /ipfs/$NAMEHASH/file.txt > expected &&
echo "IPFS" > actual && echo "IPFS" > actual &&
test_cmp expected actual test_cmp expected actual
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论