Skip to content

Commit

Permalink
tests: Replace use of preq with node-fetch
Browse files Browse the repository at this point in the history
Bug: T293853
Bug: T309772
  • Loading branch information
jdforrester committed Jun 25, 2024
1 parent 54e3bb8 commit a3585a8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 73 deletions.
133 changes: 72 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"homepage": "https://github.com/wikimedia/service-runner",
"engines": {
"node": ">=12"
"node": ">=16"
},
"dependencies": {
"bluebird": "^3.7.2",
Expand All @@ -58,7 +58,7 @@
"eslint-config-wikimedia": "0.28.2",
"mocha": "^10.2.0",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^15.1.0",
"preq": "^0.5.14"
"node-fetch": "^2.7.0",
"nyc": "^15.1.0"
}
}
20 changes: 11 additions & 9 deletions test/features/tests.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

const preq = require( 'preq' );

const TestServer = require( '../TestServer' );
const cluster = require( 'cluster' );
const fetch = require( 'node-fetch' );
const assert = require( 'assert' );
const Bluebird = require( 'bluebird' );

fetch.Promise = Bluebird;

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

// preq prevents the AssertionErrors from surfacing and failing the test
// fetch prevents the AssertionErrors from surfacing and failing the test
// performing the test this way presents them correctly
it( 'Must increment hitcount metrics when hit, no workers', () => {
const server = new TestServer( `${ __dirname }/../utils/simple_config_no_workers.yaml` );
const response = { status: null, body: null };
return server.start()
.then( () => {
preq.get( { uri: 'http://127.0.0.1:12345' } );
fetch( { uri: 'http://127.0.0.1:12345' } );
} )
.delay( 1000 )
.then( () => {
preq.get( { uri: 'http://127.0.0.1:9000' } )
fetch( { uri: 'http://127.0.0.1:9000' } )
.then( ( res ) => {
response.status = res.status;
response.body = res.body;
Expand All @@ -136,11 +138,11 @@ describe( 'service-runner tests', () => {
const response = { status: null, body: null };
return server.start()
.then( () => {
preq.get( { uri: 'http://127.0.0.1:12345' } );
fetch( { uri: 'http://127.0.0.1:12345' } );
} )
.delay( 1000 )
.then( () => {
preq.get( { uri: 'http://127.0.0.1:9000' } )
fetch( { uri: 'http://127.0.0.1:9000' } )
.then( ( res ) => {
response.status = res.status;
response.body = res.body;
Expand All @@ -162,11 +164,11 @@ describe( 'service-runner tests', () => {
const response = { status: null, body: null };
return server.start()
.then( () => {
preq.get( { uri: 'http://127.0.0.1:12345' } );
fetch( { uri: 'http://127.0.0.1:12345' } );
} )
.delay( 1000 )
.then( () => {
preq.get( { uri: 'http://127.0.0.1:9000' } )
fetch( { uri: 'http://127.0.0.1:9000' } )
.then( ( res ) => {
response.status = res.status;
response.body = res.body;
Expand Down

0 comments on commit a3585a8

Please sign in to comment.