Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Migrate block command - Closes #563 #570

Merged
merged 6 commits into from
Aug 3, 2018
Merged

Migrate block command - Closes #563 #570

merged 6 commits into from
Aug 3, 2018

Conversation

shuse2
Copy link
Contributor

@shuse2 shuse2 commented Jun 30, 2018

Description

Migration from

lisk get block

npm t
./bin/run block:get

Review checklist

@shuse2 shuse2 self-assigned this Jun 30, 2018
@shuse2 shuse2 requested a review from willclarktech June 30, 2018 11:13
@shuse2 shuse2 changed the title Migrate block command Migrate block command - Closes #563 Jul 4, 2018
@shuse2 shuse2 force-pushed the 556_migrate_config_command branch 2 times, most recently from 4669cd4 to 865d40c Compare July 16, 2018 13:22
@shuse2 shuse2 force-pushed the 563_migrate_block branch from bb6924d to 07a131f Compare August 1, 2018 15:50
@shuse2 shuse2 changed the base branch from 556_migrate_config_command to 2.0.0 August 1, 2018 15:51
Copy link
Contributor

@willclarktech willclarktech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly naming issues (plus the package.json).

blockId,
},
placeholder: {
blockId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be id: blockId to conform to the API payload.

name: 'blockIds',
required: true,
description:
'Comma separated block id(s) which you want to get the information of.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comma-separated block ID(s) to get information about.

};
const printMethodStub = sandbox.stub();
const apiClientStub = sandbox.stub();
const setupStub = test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setupTest. Also we made this a function in the account tests.

.stub(config, 'getConfig', sandbox.stub().returns({ api: apiConfig }))
.stub(api, 'default', sandbox.stub().returns(apiClientStub));

setupStub
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we match the structure in the account test?

.catch(error => expect(error.message).to.contain('Missing 1 required arg'))
.it('should throw an error when arg is not provided');

describe('block:get block', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block:get blockId

.stdout()
.stub(query, 'default', sandbox.stub().resolves(queryResult))
.command(['block:get', block])
.it('should get an block info and display as an object', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should get block info and display as an object

});
});

describe('block:get blocks', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blockIds

});

describe('block:get blocks', () => {
const blocks = ['3520445367460290306L', '2802325248134221536L'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blockIds

const queryResult = [
{
blockId: blocks[0],
name: 'i am owner',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example didn't make much sense in the account case but it makes even less sense here.

},
]);
return expect(printMethodStub).to.be.calledWithExactly(queryResult);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to put these expectations in separate .it calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.it is the end of chain, so it cannot have multiple it in one test ='(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😿

Copy link
Contributor

@willclarktech willclarktech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I get some weird behaviour running this command:

./bin/run block:get 17108498772892203620,

For account:get this kind of input errors with a 400 (validation errors) because the second address is an empty string. But with block:get I get the result for the first ID twice.

@@ -41,7 +41,7 @@ GetCommand.args = [
name: 'blockIds',
required: true,
description: 'Comma-separated block ID(s) to get information about.',
parse: input => input.split(','),
parse: input => input.split(',').filter(val => val),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like .filter(Boolean) for this kind of check.

Copy link
Contributor Author

@shuse2 shuse2 Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like
.filter(isNonEmptyString)?

@@ -115,5 +116,33 @@ describe('block:get', () => {
]);
return expect(printMethodStub).to.be.calledWithExactly(queryResult);
});

setupTest()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a similar filter + test to accounts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! i will make it on another issue/PR

@shuse2 shuse2 merged commit 9041ae0 into 2.0.0 Aug 3, 2018
@shuse2 shuse2 deleted the 563_migrate_block branch August 3, 2018 12:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants