Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,331 changes: 146 additions & 4,185 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"start": "node server.js | bunyan -o short",
"test": "STATUS=0; tap --allow-incomplete-coverage test/**/*.test.js || STATUS=$?; standard || STATUS=$?; exit $STATUS",
"test": "STATUS=0; node --test test/**/*.test.js || STATUS=$?; standard || STATUS=$?; exit $STATUS",
"test:watch": "nodemon -q -x 'npm test'"
},
"engines": {
Expand Down Expand Up @@ -33,7 +33,6 @@
"nock": "^14.0.1",
"nodemon": "^3.1.9",
"standard": "^17.1.2",
"supertest": "^7.0.0",
"tap": "^21.1.0"
"supertest": "^7.0.0"
}
}
9 changes: 5 additions & 4 deletions test/integration/event-relay-to-github-actions.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tap from 'tap'
import test from 'node:test'
import fetchMock from 'fetch-mock'
import supertest from 'supertest'

Expand All @@ -10,7 +10,7 @@ import eventRelay from '../../scripts/event-relay.js'

eventRelay(app, events)

tap.test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches', (t) => {
test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches', (t, done) => {
const jenkinsPayload = readFixture('success-payload.json')

fetchMock.mockGlobal()
Expand All @@ -23,7 +23,8 @@ tap.test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/disp
.send(jenkinsPayload)
.expect(200)
.end((err, res) => {
t.equal(err, null)
t.equal(fetchMock.callHistory.called(), true)
t.assert.strictEqual(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(), true)
done()
})
})
11 changes: 6 additions & 5 deletions test/integration/ping.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
import http from 'node:http'

import tap from 'tap'
import test from 'node:test'

import { app, events } from '../../app.js'

import ping from '../../scripts/ping.js'

ping(app, events)

tap.test('GET /ping responds with status 200 / "pong"', (t) => {
test('GET /ping responds with status 200 / "pong"', (t, done) => {
const server = app.listen()
const port = server.address().port
const url = `http://localhost:${port}/ping`

t.plan(2)
t.teardown(() => server.close())
t.after(() => server.close())

http.get(url, (res) => {
t.equal(res.statusCode, 200)
t.assert.strictEqual(res.statusCode, 200)

let data = ''
res.on('data', (chunk) => {
data += chunk
})
res.on('end', () => {
t.equal(data, 'pong')
t.assert.strictEqual(data, 'pong')
done()
})
}).on('error', (e) => {
t.fail(e)
Expand Down
72 changes: 41 additions & 31 deletions test/integration/push-jenkins-update.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tap from 'tap'
import test from 'node:test'
import fetchMock from 'fetch-mock'
import supertest from 'supertest'

Expand All @@ -13,7 +13,7 @@ fetchMock.mockGlobal()

jenkinsStatus(app, events)

tap.test('Sends POST requests to https://api.github.com/repos/nodejs/node/statuses/<SHA>', (t) => {
test('Sends POST requests to https://api.github.com/repos/nodejs/node/statuses/<SHA>', (t, done) => {
const jenkinsPayload = readFixture('success-payload.json')

const listCommitsUrl = setupListCommitsMock('node')
Expand All @@ -28,13 +28,14 @@ tap.test('Sends POST requests to https://api.github.com/repos/nodejs/node/status
.send(jenkinsPayload)
.expect(200)
.end((err, res) => {
t.equal(err, null)
t.equal(fetchMock.callHistory.called(url), true)
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
t.assert.strictEqual(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
done()
})
})

tap.test('Allows repository name to be provided with URL parameter when pushing job started', (t) => {
test('Allows repository name to be provided with URL parameter when pushing job started', (t, done) => {
const jenkinsPayload = readFixture('pending-payload.json')

const listCommitsUrl = setupListCommitsMock('citgm')
Expand All @@ -49,13 +50,14 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
.send(jenkinsPayload)
.expect(200)
.end((err, res) => {
t.equal(err, null)
t.equal(fetchMock.callHistory.called(url), true)
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
t.assert.strictEqual(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
done()
})
})

tap.test('Allows repository name to be provided with URL parameter when pushing job ended', (t) => {
test('Allows repository name to be provided with URL parameter when pushing job ended', (t, done) => {
const jenkinsPayload = readFixture('success-payload.json')

const listCommitsUrl = setupListCommitsMock('citgm')
Expand All @@ -70,13 +72,14 @@ tap.test('Allows repository name to be provided with URL parameter when pushing
.send(jenkinsPayload)
.expect(200)
.end((err, res) => {
t.equal(err, null)
t.equal(fetchMock.callHistory.called(url), true)
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
t.assert.strictEqual(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
done()
})
})

tap.test('Forwards payload provided in incoming POST to GitHub status API', (t) => {
test('Forwards payload provided in incoming POST to GitHub status API', (t, done) => {
const fixture = readFixture('success-payload.json')

const listCommitsUrl = setupListCommitsMock('node')
Expand All @@ -97,13 +100,14 @@ tap.test('Forwards payload provided in incoming POST to GitHub status API', (t)
.send(fixture)
.expect(200)
.end((err, res) => {
t.equal(err, null)
t.equal(fetchMock.callHistory.called(url), true)
t.equal(fetchMock.callHistory.called(listCommitsUrl), true)
t.assert.strictEqual(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
t.assert.strictEqual(fetchMock.callHistory.called(listCommitsUrl), true)
done()
})
})

tap.test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request', (t) => {
test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request', (t, done) => {
const fixture = readFixture('jenkins-test-pull-request-success-payload.json')

const url = 'https://api.github.com/repos/nodejs/node/issues/12345/comments'
Expand All @@ -125,12 +129,13 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
.send(fixture)
.expect(200)
.end((err, res) => {
t.equal(fetchMock.callHistory.called(url), true)
t.equal(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
t.assert.strictEqual(err, null)
done()
})
})

tap.test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request-lite-pipeline', (t) => {
test('Posts a CI comment in the related PR when Jenkins build is named node-test-pull-request-lite-pipeline', (t, done) => {
const fixture = readFixture('jenkins-test-pull-request-success-payload.json')
fixture.identifier = 'node-test-pull-request-lite-pipeline'

Expand All @@ -153,12 +158,13 @@ tap.test('Posts a CI comment in the related PR when Jenkins build is named node-
.send(fixture)
.expect(200)
.end((err, res) => {
t.equal(fetchMock.callHistory.called(url), true)
t.equal(err, null)
t.assert.strictEqual(fetchMock.callHistory.called(url), true)
t.assert.strictEqual(err, null)
done()
})
})

tap.test('Responds with 400 / "Bad request" when incoming request has invalid payload', (t) => {
test('Responds with 400 / "Bad request" when incoming request has invalid payload', (t, done) => {
const fixture = readFixture('invalid-payload.json')

// don't care about the results, just want to prevent any HTTP request ever being made
Expand All @@ -171,11 +177,12 @@ tap.test('Responds with 400 / "Bad request" when incoming request has invalid pa
.send(fixture)
.expect(400, 'Invalid payload')
.end((err, res) => {
t.equal(err, null)
t.assert.strictEqual(err, null)
done()
})
})

tap.test('Responds with 400 / "Bad request" when build started status update is not related to a pull request', (t) => {
test('Responds with 400 / "Bad request" when build started status update is not related to a pull request', (t, done) => {
const fixture = readFixture('jenkins-staging-failure-payload.json')

// don't care about the results, just want to prevent any HTTP request ever being made
Expand All @@ -188,11 +195,12 @@ tap.test('Responds with 400 / "Bad request" when build started status update is
.send(fixture)
.expect(400, 'Will only push builds related to pull requests')
.end((err, res) => {
t.equal(err, null)
t.assert.strictEqual(err, null)
done()
})
})

tap.test('Responds with 400 / "Bad request" when build ended status update is not related to a pull request', (t) => {
test('Responds with 400 / "Bad request" when build ended status update is not related to a pull request', (t, done) => {
const fixture = readFixture('jenkins-staging-failure-payload.json')

// don't care about the results, just want to prevent any HTTP request ever being made
Expand All @@ -205,11 +213,12 @@ tap.test('Responds with 400 / "Bad request" when build ended status update is no
.send(fixture)
.expect(400, 'Will only push builds related to pull requests')
.end((err, res) => {
t.equal(err, null)
t.assert.strictEqual(err, null)
done()
})
})

tap.test('Responds with 400 / "Bad request" when incoming providing invalid repository name', (t) => {
test('Responds with 400 / "Bad request" when incoming providing invalid repository name', (t, done) => {
const fixture = readFixture('pending-payload.json')

// don't care about the results, just want to prevent any HTTP request ever being made
Expand All @@ -222,7 +231,8 @@ tap.test('Responds with 400 / "Bad request" when incoming providing invalid repo
.send(fixture)
.expect(400, 'Invalid repository')
.end((err, res) => {
t.equal(err, null)
t.assert.strictEqual(err, null)
done()
})
})

Expand Down
56 changes: 28 additions & 28 deletions test/unit/node-owners.test.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
import tap from 'tap'
import test from 'node:test'

import { Owners } from '../../lib/node-owners.js'
import readFixture from '../read-fixture.js'

const ownersFile = readFixture('CODEOWNERS')

tap.test('single file single team match', (t) => {
test('single file single team match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['file1']),
['@nodejs/test1']
)
t.end()
done()
})

tap.test('double file single team match', (t) => {
test('double file single team match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['file1', 'file4']),
['@nodejs/test1']
)
t.end()
done()
})

tap.test('double file double individual team match', (t) => {
test('double file double individual team match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['file1', 'file2']),
['@nodejs/test1', '@nodejs/test2']
)
t.end()
done()
})

tap.test('single file double team match', (t) => {
test('single file double team match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['file3']),
['@nodejs/test1', '@nodejs/test2']
)
t.end()
done()
})

tap.test('double file triple team match (1 + 2)', (t) => {
test('double file triple team match (1 + 2)', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['file5', 'file3']),
['@nodejs/test1', '@nodejs/test2', '@nodejs/test3']
)
t.end()
done()
})

tap.test('folder match', (t) => {
test('folder match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['folder1/file5']),
['@nodejs/test3']
)
t.end()
done()
})

tap.test('extension match', (t) => {
test('extension match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['folder2/file1.js']),
['@nodejs/test4', '@nodejs/test5']
)
t.end()
done()
})

tap.test('no match', (t) => {
test('no match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['unknown']),
[]
)
t.end()
done()
})

tap.test('no match + single match', (t) => {
test('no match + single match', (t, done) => {
const owners = Owners.fromFile(ownersFile)
t.strictSame(
t.assert.deepStrictEqual(
owners.getOwnersForPaths(['unknown', 'file1']),
['@nodejs/test1']
)
t.end()
done()
})
Loading