Skip to content

Commit

Permalink
Upgrade probot
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdothtml authored and uber-workflow-bot[bot] committed May 13, 2019
1 parent a4dd7ea commit 3eca5d0
Show file tree
Hide file tree
Showing 6 changed files with 451 additions and 220 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
npm-debug.log
*.pem
./*.pem
!__tests__/__fixtures__/mock-cert.pem
.env
27 changes: 27 additions & 0 deletions __tests__/__fixtures__/mock-cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAli7V49NdZe+XYC1pLaHM0te8kiDmZBJ1u2HJHN8GdbROB6NO
VpC3xK7NxQn6xpvZ9ux20NvcDvGle+DOptZztBH+np6h2jZQ1/kD1yG1eQvVH4th
/9oqHuIjmIfO8lIe4Hyd5Fw5xHkGqVETTGR+0c7kdZIlHmkOregUGtMYZRUi4YG+
q0w+uFemiHpGKXbeCIAvkq7aIkisEzvPWfSyYdA6WJHpxFk7tD7D8VkzABLVRHCq
AuyqPG39BhGZcGLXx5rGK56kDBJkyTR1t3DkHpwX+JKNG5UYNwOG4LcQj1fteeta
TdkYUMjIyWbanlMYyC+dq7B5fe7el99jXQ1gXwIDAQABAoIBADKfiPOpzKLOtzzx
MbHzB0LO+75aHq7+1faayJrVxqyoYWELuB1P3NIMhknzyjdmU3t7S7WtVqkm5Twz
lBUC1q+NHUHEgRQ4GNokExpSP4SU63sdlaQTmv0cBxmkNarS6ZuMBgDy4XoLvaYX
MSUf/uukDLhg0ehFS3BteVFtdJyllhDdTenF1Nb1rAeN4egt8XLsE5NQDr1szFEG
xH5lb+8EDtzgsGpeIddWR64xP0lDIKSZWst/toYKWiwjaY9uZCfAhvYQ1RsO7L/t
sERmpYgh+rAZUh/Lr98EI8BPSPhzFcSHmtqzzejvC5zrZPHcUimz0CGA3YBiLoJX
V1OrxmECgYEAxkd8gpmVP+LEWB3lqpSvJaXcGkbzcDb9m0OPzHUAJDZtiIIf0UmO
nvL68/mzbCHSj+yFjZeG1rsrAVrOzrfDCuXjAv+JkEtEx0DIevU1u60lGnevOeky
r8Be7pmymFB9/gzQAd5ezIlTv/COgoO986a3h1yfhzrrzbqSiivw308CgYEAwecI
aZZwqH3GifR+0+Z1B48cezA5tC8LZt5yObGzUfxKTWy30d7lxe9N59t0KUVt/QL5
qVkd7mqGzsUMyxUN2U2HVnFTWfUFMhkn/OnCnayhILs8UlCTD2Xxoy1KbQH/9FIr
xf0pbMNJLXeGfyRt/8H+BzSZKBw9opJBWE4gqfECgYBp9FdvvryHuBkt8UQCRJPX
rWsRy6pY47nf11mnazpZH5Cmqspv3zvMapF6AIxFk0leyYiQolFWvAv+HFV5F6+t
Si1mM8GCDwbA5zh6pEBDewHhw+UqMBh63HSeUhmi1RiOwrAA36CO8i+D2Pt+eQHv
ir52IiPJcs4BUNrv5Q1BdwKBgBHgVNw3LGe8QMOTMOYkRwHNZdjNl2RPOgPf2jQL
d/bFBayhq0jD/fcDmvEXQFxVtFAxKAc+2g2S8J67d/R5Gm/AQAvuIrsWZcY6n38n
pfOXaLt1x5fnKcevpFlg4Y2vM4O416RHNLx8PJDehh3Oo/2CSwMrDDuwbtZAGZok
icphAoGBAI74Tisfn+aeCZMrO8KxaWS5r2CD1KVzddEMRKlJvSKTY+dOCtJ+XKj1
OsZdcDvDC5GtgcywHsYeOWHldgDWY1S8Z/PUo4eK9qBXYBXp3JEZQ1dqzFdz+Txi
rBn2WsFLsxV9j2/ugm0PqWVBcU2bPUCwvaRu3SOms2teaLwGCkhr
-----END RSA PRIVATE KEY-----
21 changes: 16 additions & 5 deletions __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@

/* eslint-env jest */

const fs = require('fs');
const path = require('path');
const nock = require('nock');
const mergePRApp = require('../index.js');
const {Probot} = require('probot');

const MOCK_CERT_PATH = path.resolve(__dirname, '__fixtures__/mock-cert.pem');
// mock cert copied from copied from:
// https://github.com/probot/create-probot-app/blob/de9078d/templates/basic-js/test/fixtures/mock-cert.pem
const MOCK_CERT = fs.readFileSync(MOCK_CERT_PATH, 'utf-8');
const fixtures = {
listCommits: require('./__fixtures__/listCommits.js'),
payload: require('./__fixtures__/issue_comment.created.js'),
Expand All @@ -21,11 +28,12 @@ describe('probot-app-merge-pr', () => {
let probot;

beforeEach(() => {
probot = new Probot({});
const app = probot.load(mergePRApp);
probot = new Probot({
id: 123,
cert: MOCK_CERT,
});

// just return a test token
app.app = () => 'test';
probot.load(mergePRApp);
});

test('merges the PR with commit authors as co-authors', async () => {
Expand All @@ -39,7 +47,10 @@ describe('probot-app-merge-pr', () => {

const mergeRequest = new Promise(resolve => {
nock('https://api.github.com')
.put('/repos/fusionjs/test-repo/pulls/1/merge', resolve)
.put('/repos/fusionjs/test-repo/pulls/1/merge', body => {
resolve(body);
return true;
})
.reply(200);
});

Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = robot => {
}

const {github} = context;
const permissions = await github.repos.reviewUserPermissionLevel(
const permissions = await github.repos.getCollaboratorPermissionLevel(
context.repo({
username: user.login,
}),
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = robot => {
const authorTrailerSet = await github.pullRequests
.listCommits(
context.repo({
number: issue.number,
pull_number: issue.number,
}),
)
.then(res =>
Expand All @@ -68,7 +68,7 @@ module.exports = robot => {

await github.pullRequests.merge(
context.repo({
number: issue.number,
pull_number: issue.number,
commit_title: issue.title,
commit_message,
merge_method,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"fix": "eslint . --fix"
},
"dependencies": {
"probot": "7.5.0"
"probot": "^9.2.10"
},
"devDependencies": {
"eslint": "5.14.1",
Expand Down
Loading

0 comments on commit 3eca5d0

Please sign in to comment.