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

Use Sinon for mocking. Fill a test gap for Linux PATH. Add tests with task runner. #7054

Merged
merged 9 commits into from
May 7, 2018

Conversation

brcrista
Copy link
Contributor

While working on the Conda task, it would be useful to introduced a generalized way for mocking dependencies rather than mocking ad-hoc. Sinon.JS looks like a good option here, so I refactored the tests for Use Python Version to use it to give myself a model for how to use it.

Note that this improves test coverage since Sinon will complain if you forget to check an invocation of a test spy. In particular, using Sinon caught the following test gap:

assert(prependPathSafe.calledWithExactly(path.join('findLocalTool', 'bin')));

@bryanmacfarlane
Copy link
Contributor

I would like for tasks in this repo to be coded the same way since they are reference examples (the reason we open sourced this). I'm trying to discern whether this is a necessity and blocker or whether it's a preference. @madhurig

@brcrista brcrista changed the title Use Sinon for mocking. Fill a test gap for Linux PATH Use Sinon for mocking. Fill a test gap for Linux PATH. Add tests with task runner. May 1, 2018
@@ -19,6 +19,8 @@
"devDependencies": {
"@types/mocha": "^2.2.48",
"@types/mockery": "^1.4.29",
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why do the typing versions not match the package versions?

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 looks like the @types packages are versioned following their corresponding JS packages, but these must be lagging. They're not necessarily maintained by the authors of the JS packages. I haven't noticed any issues.

(The old "typings" files that were checked into source control have been deprecated in favor of just using NPM packages, which is what these @types packages are.)

@brcrista brcrista merged commit 5f0da7b into master May 7, 2018
@brcrista brcrista deleted the users/brcrista/python-sinon branch May 29, 2018 18:50
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.

3 participants