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
feat: support adding labels to PRs #173
Conversation
Codecov Report
@@ Coverage Diff @@
## master #173 +/- ##
==========================================
+ Coverage 87.98% 88.09% +0.11%
==========================================
Files 23 24 +1
Lines 2222 2294 +72
Branches 170 173 +3
==========================================
+ Hits 1955 2021 +66
- Misses 266 272 +6
Partials 1 1
Continue to review full report at Codecov.
|
What is a good way to cover the lines added to |
@noahdietz, for your issue test why don't you do this:
This will pull in your helper from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation looks really solid to me.
What's your specific use case out of curiosity?
Also, I think one coverage issue is that the call to
The |
issue_number: number, | ||
labels?: string[] | ||
): Promise<string[]> { | ||
if (!labels || labels.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcoe moved the check on labels
into addLabels
instead of around the call site.
it('No-op undefined labels', async () => { | ||
// setup | ||
const stub = sandbox.stub(octokit.issues, 'addLabels').resolves(); | ||
// tests | ||
const resultingLabels = await addLabels( | ||
octokit, | ||
upstream, | ||
origin, | ||
issue_number | ||
); | ||
sandbox.assert.neverCalledWith(stub, sinon.match.any); | ||
expect(resultingLabels).to.deep.equal([]); | ||
}); | ||
|
||
it('No-op with empty labels', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcoe added no-op tests.
@@ -116,6 +118,20 @@ describe('Make PR main function', () => { | |||
expect(testMaintainersCanModify).equals(maintainersCanModify); | |||
expect(testPrimary).equals(primary); | |||
}, | |||
addLabels: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcoe Added stub helpers for what actually seems to be the main tests for createPullRequest
.
Thanks for your review @bcoe! I tweaked things a bit WRT the no-op case fo |
Thanks guys for the reviews. I can't actually merge this PR so one of you will have to. Thanks! |
🤖 I have created a release \*beep\* \*boop\* --- ## [1.9.0](https://www.github.com/googleapis/code-suggester/compare/v1.8.2...v1.9.0) (2021-02-25) ### Features * support adding labels to PRs ([#173](https://www.github.com/googleapis/code-suggester/issues/173)) ([df55616](https://www.github.com/googleapis/code-suggester/commit/df55616ebc02dc702d828d12b5746830d90e61d4)) ### Bug Fixes * **deps:** update dependency @types/yargs to v16 ([#168](https://www.github.com/googleapis/code-suggester/issues/168)) ([6cc6657](https://www.github.com/googleapis/code-suggester/commit/6cc6657fa5d5580432afd6d76df8e25eb6cff246)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Adds support for adding labels to pull requests.
Fixes #172