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

T/43: Added tests #44

Merged
merged 13 commits into from
Feb 13, 2017
Merged

T/43: Added tests #44

merged 13 commits into from
Feb 13, 2017

Conversation

pomek
Copy link
Member

@pomek pomek commented Feb 13, 2017

Fix: Fixed various minor issues with the commands. Introduced missing tests. Closes #31. Closes #41. Closes #3. Closes #43.

// Package is already cloned.
if ( fs.existsSync( destinationPath ) ) {
log.info( `Package "${ data.packageName }" is already cloned. Skipping.` );
let promise = Promise.resolve( '' );
Copy link
Member

Choose a reason for hiding this comment

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

Why the empty string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Logger requires string as a param. I will correct it.

return resolve( { logs: log.all() } );
}
// Package is not cloned.
if ( !fs.existsSync( destinationPath ) ) {
Copy link
Member

@Reinmar Reinmar Feb 13, 2017

Choose a reason for hiding this comment

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

Switch the order of ifs. It doesn't make sense to check if( !cond ) if you have else.

@Reinmar
Copy link
Member

Reinmar commented Feb 13, 2017

Please list which commit fixed which issue. Otherwise, this PR will need to be split. I must be able to review it and now it's a mix of new things and bug fixes.

} );
} );

it( 'installs dependencies of cloned package', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated test name.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry. The other one is devDeps.

Copy link
Member Author

@pomek pomek Feb 13, 2017

Choose a reason for hiding this comment

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

Fixed in cc8e24f.

@pomek
Copy link
Member Author

pomek commented Feb 13, 2017

Try to use the list - https://github.com/cksource/mgit2/pull/44/commits. Maybe it will be helpful.

const exec = stubs.execCommand.execute;

exec.returns( Promise.resolve( {
logs: getCommandLogs( ' M first-file.js\ ?? second-file.js' )
Copy link
Member

Choose a reason for hiding this comment

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

\ -> \n?


return resolve( { logs: log.all() } );
// Package is not cloned.
Copy link
Member

Choose a reason for hiding this comment

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

Wrong comment.

if ( fs.existsSync( destinationPath ) ) {
log.info( `Package "${ data.packageName }" is already cloned.` );
} else {
const command = [
Copy link
Member

Choose a reason for hiding this comment

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

Since this condition sets the promise to exec( cmd ), the previous condition could set it to Promise.resolve(). This would be clearer.


exec( command )
promise
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing return statement (?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I see now where resolve and reject parts are. But it looks a little bit strange for me to return a promise which has another promise inside and which is even not returned ;) Maybe it could be written step by step with .then() method and get 27-42 lines before the return statement?

Copy link
Member Author

Choose a reason for hiding this comment

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

A promise inside another promise can not be returned because you need to call resolve or reject function.

OTOH maybe the "wrapper" Promise is not necessary. Who knows? :D

@pomek pomek merged commit 5751eb7 into master Feb 13, 2017
@pomek pomek deleted the t/43 branch February 13, 2017 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants