Skip to content

Commit

Permalink
refactor(1079): Refactor addDeployKey to use request scope format and…
Browse files Browse the repository at this point in the history
… update tests (#169)
  • Loading branch information
supra08 authored Aug 10, 2020
1 parent c1e4cfb commit 72e9b34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,10 @@ class GithubScm extends Scm {

try {
await this.breaker.runCommand({
action: 'createDeployKey',
scopeType: 'repos',
scopeType: 'request',
route: `POST /repos/${owner}/${repo}/keys`,
token,
params: {
owner,
repo,
title: DEPLOY_KEY_GENERATOR_CONFIG.DEPLOY_KEY_TITLE,
key: pubKey,
read_only: true
Expand Down
5 changes: 2 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ describe('index', function () {
getCommitRefSha: sinon.stub(),
getContents: sinon.stub(),
listHooks: sinon.stub(),
listBranches: sinon.stub(),
createDeployKey: sinon.stub()
listBranches: sinon.stub()
},
users: {
getByUsername: sinon.stub()
Expand Down Expand Up @@ -1946,7 +1945,7 @@ jobs:

it('returns a private key', async () => {
generateDeployKeyStub.returns(Promise.resolve({ pubKey, key: privKey }));
githubMock.repos.createDeployKey.resolves({ data: pubKey });
githubMock.request.resolves({ data: pubKey });
const privateKey = await scm.addDeployKey(addDepKeyConfig);

assert.isString(privateKey);
Expand Down

0 comments on commit 72e9b34

Please sign in to comment.