Skip to content

Commit a3585a8

Browse files
committed
tests: Replace use of preq with node-fetch
Bug: T293853 Bug: T309772
1 parent 54e3bb8 commit a3585a8

File tree

3 files changed

+86
-73
lines changed

3 files changed

+86
-73
lines changed

package-lock.json

Lines changed: 72 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"homepage": "https://github.com/wikimedia/service-runner",
3333
"engines": {
34-
"node": ">=12"
34+
"node": ">=16"
3535
},
3636
"dependencies": {
3737
"bluebird": "^3.7.2",
@@ -58,7 +58,7 @@
5858
"eslint-config-wikimedia": "0.28.2",
5959
"mocha": "^10.2.0",
6060
"mocha-lcov-reporter": "^1.3.0",
61-
"nyc": "^15.1.0",
62-
"preq": "^0.5.14"
61+
"node-fetch": "^2.7.0",
62+
"nyc": "^15.1.0"
6363
}
6464
}

test/features/tests.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
22

3-
const preq = require( 'preq' );
4-
53
const TestServer = require( '../TestServer' );
64
const cluster = require( 'cluster' );
5+
const fetch = require( 'node-fetch' );
76
const assert = require( 'assert' );
7+
const Bluebird = require( 'bluebird' );
8+
9+
fetch.Promise = Bluebird;
810

911
describe( 'service-runner tests', () => {
1012
it( 'Must start and stop a simple service, no workers', () => {
@@ -103,18 +105,18 @@ describe( 'service-runner tests', () => {
103105
.finally( () => process.removeListener( 'warning', warningListener ) );
104106
} );
105107

106-
// preq prevents the AssertionErrors from surfacing and failing the test
108+
// fetch prevents the AssertionErrors from surfacing and failing the test
107109
// performing the test this way presents them correctly
108110
it( 'Must increment hitcount metrics when hit, no workers', () => {
109111
const server = new TestServer( `${ __dirname }/../utils/simple_config_no_workers.yaml` );
110112
const response = { status: null, body: null };
111113
return server.start()
112114
.then( () => {
113-
preq.get( { uri: 'http://127.0.0.1:12345' } );
115+
fetch( { uri: 'http://127.0.0.1:12345' } );
114116
} )
115117
.delay( 1000 )
116118
.then( () => {
117-
preq.get( { uri: 'http://127.0.0.1:9000' } )
119+
fetch( { uri: 'http://127.0.0.1:9000' } )
118120
.then( ( res ) => {
119121
response.status = res.status;
120122
response.body = res.body;
@@ -136,11 +138,11 @@ describe( 'service-runner tests', () => {
136138
const response = { status: null, body: null };
137139
return server.start()
138140
.then( () => {
139-
preq.get( { uri: 'http://127.0.0.1:12345' } );
141+
fetch( { uri: 'http://127.0.0.1:12345' } );
140142
} )
141143
.delay( 1000 )
142144
.then( () => {
143-
preq.get( { uri: 'http://127.0.0.1:9000' } )
145+
fetch( { uri: 'http://127.0.0.1:9000' } )
144146
.then( ( res ) => {
145147
response.status = res.status;
146148
response.body = res.body;
@@ -162,11 +164,11 @@ describe( 'service-runner tests', () => {
162164
const response = { status: null, body: null };
163165
return server.start()
164166
.then( () => {
165-
preq.get( { uri: 'http://127.0.0.1:12345' } );
167+
fetch( { uri: 'http://127.0.0.1:12345' } );
166168
} )
167169
.delay( 1000 )
168170
.then( () => {
169-
preq.get( { uri: 'http://127.0.0.1:9000' } )
171+
fetch( { uri: 'http://127.0.0.1:9000' } )
170172
.then( ( res ) => {
171173
response.status = res.status;
172174
response.body = res.body;

0 commit comments

Comments
 (0)