Skip to content

Commit

Permalink
modify command name and update the test
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kejie Zhang <601172892@qq.com>
  • Loading branch information
kjzz committed Sep 11, 2018
1 parent 7de83f2 commit b7ea4bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
progressOptionName = "progress"
trickleOptionName = "trickle"
wrapOptionName = "wrap-with-directory"
pathName = "name"
stdinPathName = "stdin-name"
hiddenOptionName = "hidden"
onlyHashOptionName = "only-hash"
chunkerOptionName = "chunker"
Expand Down Expand Up @@ -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(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
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.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),
Expand Down Expand Up @@ -183,7 +183,7 @@ You can now check what blocks have been created by:
hashFunStr, _ := req.Options[hashOptionName].(string)
inline, _ := req.Options[inlineOptionName].(bool)
inlineLimit, _ := req.Options[inlineLimitOptionName].(int)
pathName, _ := req.Options[pathName].(string)
pathName, _ := req.Options[stdinPathName].(string)

// The arguments are subject to the following constraints.
//
Expand Down
12 changes: 6 additions & 6 deletions test/sharness/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,22 @@ test_add_cat_file() {
test_cmp zero-length-file zero-length-file_out
'

test_expect_success "ipfs add --name" '
test_expect_success "ipfs add --stdin-name" '
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 &&
test_cmp expected actual
'

test_expect_success "ipfs add --name -w" '
test_expect_success "ipfs add --stdin-name -w" '
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 &&
test_cmp expected actual
'

test_expect_success "ipfs cat with name" '
NAMEHASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) &&
test_expect_success "ipfs cat with stdin-name" '
NAMEHASH=$(echo "IPFS" | ipfs add -w --stdin-name file.txt -Q) &&
ipfs cat /ipfs/$NAMEHASH/file.txt > expected &&
echo "IPFS" > actual &&
test_cmp expected actual
Expand Down

0 comments on commit b7ea4bf

Please sign in to comment.