Skip to content
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

Fix key rename command output error #4962

Merged
merged 2 commits into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/commands/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ var keyRenameCmd = &cmds.Command{
},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
k, ok := res.Output().(*KeyRenameOutput)
v, err := unwrapOutput(res.Output())
if err != nil {
return nil, err
}
k, ok := v.(*KeyRenameOutput)
if !ok {
return nil, fmt.Errorf("expected a KeyRenameOutput as command result")
}
Expand Down
7 changes: 7 additions & 0 deletions test/sharness/t0165-keystore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ test_key_cmd() {
test_cmp list_exp list_out
'

test_expect_success "key rename rename key output succeeds" '
key_content=$(ipfs key gen key1 --type=rsa --size=2048) &&
ipfs key rename key1 key2 >rs &&
echo "Key $key_content renamed to key2" >expect &&
test_cmp rs expect
'

test_expect_success "key rename can't rename self" '
test_must_fail ipfs key rename self bar 2>&1 | tee key_rename_out &&
grep -q "Error: cannot rename key with name" key_rename_out
Expand Down