Skip to content

Commit c541205

Browse files
committed
test: verify jenkins event gets relayed as repository event
1 parent 9ef8f37 commit c541205

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict'
2+
3+
const tap = require('tap')
4+
const url = require('url')
5+
const nock = require('nock')
6+
const supertest = require('supertest')
7+
8+
const { app, events } = require('../../app')
9+
10+
const readFixture = require('../read-fixture')
11+
12+
require('../../scripts/event-relay')(app, events)
13+
14+
tap.test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches', (t) => {
15+
const jenkinsPayload = readFixture('success-payload.json')
16+
17+
nock('https://api.github.com')
18+
.filteringPath(ignoreQueryParams)
19+
.post('/repos/nodejs/node/dispatches')
20+
.reply(204)
21+
.on('replied', (req, interceptor) => {
22+
t.doesNotThrow(() => interceptor.scope.done())
23+
})
24+
25+
t.plan(2)
26+
27+
supertest(app)
28+
.post('/node/jenkins/start')
29+
.send(jenkinsPayload)
30+
.expect(200)
31+
.end((err, res) => {
32+
t.equal(err, null)
33+
})
34+
})
35+
36+
function ignoreQueryParams (pathAndQuery) {
37+
return url.parse(pathAndQuery, true).pathname
38+
}

0 commit comments

Comments
 (0)