Skip to content

Commit e34a7c8

Browse files
committed
Remove majority of fake timers use while testing
As a precursor to running test assertions after we *know* all work has been done, most our use of fake timers gets removed here as it will not be needed anymore and even causes some challenges not easily solved when requests starts hanging due to work not having finished yet and the culprit is timers not running as they normally do.
1 parent 249b062 commit e34a7c8

File tree

3 files changed

+1
-19
lines changed

3 files changed

+1
-19
lines changed

test/integration/node-labels-webhook.test.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const url = require('url')
55
const nock = require('nock')
66
const supertest = require('supertest')
77
const proxyquire = require('proxyquire')
8-
const lolex = require('lolex')
98

109
const testStubs = {
1110
'./github-secret': {
@@ -24,7 +23,6 @@ const readFixture = require('../read-fixture')
2423
setupNoRequestMatchHandler()
2524

2625
tap.test('Sends POST request to https://api.github.com/repos/nodejs/node/issues/<PR-NUMBER>/labels', (t) => {
27-
const clock = lolex.install()
2826
const expectedLabels = ['timers']
2927
const webhookPayload = readFixture('pull-request-opened.json')
3028

@@ -48,7 +46,6 @@ tap.test('Sends POST request to https://api.github.com/repos/nodejs/node/issues/
4846
filesScope.done()
4947
existingRepoLabelsScope.done()
5048
newLabelsScope.done()
51-
clock.uninstall()
5249
})
5350

5451
supertest(app)
@@ -57,13 +54,11 @@ tap.test('Sends POST request to https://api.github.com/repos/nodejs/node/issues/
5754
.send(webhookPayload)
5855
.expect(200)
5956
.end((err, res) => {
60-
clock.runAll()
6157
t.equal(err, null)
6258
})
6359
})
6460

6561
tap.test('Adds v6.x label when PR is targeting the v6.x-staging branch', (t) => {
66-
const clock = lolex.install()
6762
const expectedLabels = ['timers', 'v6.x']
6863
const webhookPayload = readFixture('pull-request-opened-v6.x.json')
6964

@@ -87,7 +82,6 @@ tap.test('Adds v6.x label when PR is targeting the v6.x-staging branch', (t) =>
8782
filesScope.done()
8883
existingRepoLabelsScope.done()
8984
newLabelsScope.done()
90-
clock.uninstall()
9185
})
9286

9387
supertest(app)
@@ -96,14 +90,12 @@ tap.test('Adds v6.x label when PR is targeting the v6.x-staging branch', (t) =>
9690
.send(webhookPayload)
9791
.expect(200)
9892
.end((err, res) => {
99-
clock.runAll()
10093
t.equal(err, null)
10194
})
10295
})
10396

10497
// reported bug: https://github.com/nodejs/github-bot/issues/58
10598
tap.test('Does not create labels which does not already exist', (t) => {
106-
const clock = lolex.install()
10799
const webhookPayload = readFixture('pull-request-opened-mapproxy.json')
108100

109101
const filesScope = nock('https://api.github.com')
@@ -120,7 +112,6 @@ tap.test('Does not create labels which does not already exist', (t) => {
120112
t.tearDown(() => {
121113
filesScope.done()
122114
existingRepoLabelsScope.done()
123-
clock.uninstall()
124115
})
125116

126117
supertest(app)
@@ -129,14 +120,12 @@ tap.test('Does not create labels which does not already exist', (t) => {
129120
.send(webhookPayload)
130121
.expect(200)
131122
.end((err, res) => {
132-
clock.runAll()
133123
t.equal(err, null)
134124
})
135125
})
136126

137127
// reported bug: https://github.com/nodejs/github-bot/issues/92
138128
tap.test('Adds V8 Engine label when PR has deps/v8 file changes', (t) => {
139-
const clock = lolex.install()
140129
const expectedLabels = ['V8 Engine']
141130
const webhookPayload = readFixture('pull-request-opened-v8.json')
142131

@@ -160,7 +149,6 @@ tap.test('Adds V8 Engine label when PR has deps/v8 file changes', (t) => {
160149
filesScope.done()
161150
existingRepoLabelsScope.done()
162151
newLabelsScope.done()
163-
clock.uninstall()
164152
})
165153

166154
supertest(app)
@@ -169,7 +157,6 @@ tap.test('Adds V8 Engine label when PR has deps/v8 file changes', (t) => {
169157
.send(webhookPayload)
170158
.expect(200)
171159
.end((err, res) => {
172-
clock.runAll()
173160
t.equal(err, null)
174161
})
175162
})

test/integration/trigger-jenkins-build.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const url = require('url')
55
const nock = require('nock')
66
const supertest = require('supertest')
77
const proxyquire = require('proxyquire')
8-
const lolex = require('lolex')
98
const readFixture = require('../read-fixture')
109

1110
const app = proxyquire('../../app', {
@@ -19,8 +18,6 @@ const app = proxyquire('../../app', {
1918
})
2019

2120
tap.test('Sends POST request to https://ci.nodejs.org', (t) => {
22-
const clock = lolex.install()
23-
2421
const originalJobUrlValue = process.env.JENKINS_JOB_URL_NODE
2522
const originalTokenValue = process.env.JENKINS_BUILD_TOKEN_NODE
2623
process.env.JENKINS_JOB_NODE = 'node-test-pull-request-lite-pipeline'
@@ -48,7 +45,6 @@ tap.test('Sends POST request to https://ci.nodejs.org', (t) => {
4845
collaboratorsScope.done()
4946
ciJobScope.done()
5047
commentScope.done()
51-
clock.uninstall()
5248
})
5349

5450
supertest(app)
@@ -59,7 +55,6 @@ tap.test('Sends POST request to https://ci.nodejs.org', (t) => {
5955
.end((err, res) => {
6056
process.env.JENKINS_JOB_URL_NODE = originalJobUrlValue
6157
process.env.JENKINS_BUILD_TOKEN_NODE = originalTokenValue
62-
clock.runAll()
6358
t.equal(err, null)
6459
})
6560
})

test/unit/node-repo.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict'
22

3-
const lolex = require('lolex')
43
const proxyquire = require('proxyquire')
54
const sinon = require('sinon')
65
const tap = require('tap')
6+
const lolex = require('lolex')
77

88
const logger = require('../../lib/logger')
99
const githubClient = require('../../lib/github-client')

0 commit comments

Comments
 (0)