Skip to content

Commit

Permalink
fix: remove server.unref from tests (#3790) (#3815)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-parra committed Apr 3, 2022
1 parent 15d9955 commit a4b21f0
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 96 deletions.
6 changes: 3 additions & 3 deletions test/async-await.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test('async await', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -410,7 +410,7 @@ test('promise was fulfilled with undefined', t => {

fastify.listen({ port: 0 }, (err) => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -452,7 +452,7 @@ test('error is not logged because promise was fulfilled with undefined but respo

fastify.listen({ port: 0 }, (err) => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down
2 changes: 1 addition & 1 deletion test/bodyLimit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('bodyLimit', t => {

fastify.listen({ port: 0 }, function (err) {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down
6 changes: 3 additions & 3 deletions test/custom-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ test('contentTypeParser should handle multiple custom parsers', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down Expand Up @@ -176,7 +176,7 @@ test('contentTypeParser should handle an array of custom contentTypes', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down Expand Up @@ -966,7 +966,7 @@ test('Should parse empty bodies as a string', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down
18 changes: 9 additions & 9 deletions test/decorator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ test('decorateReply inside register', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -182,7 +182,7 @@ test('decorateReply as plugin (inside .after)', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -230,7 +230,7 @@ test('decorateReply as plugin (outside .after)', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -276,7 +276,7 @@ test('decorateRequest inside register', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -324,7 +324,7 @@ test('decorateRequest as plugin (inside .after)', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -372,7 +372,7 @@ test('decorateRequest as plugin (outside .after)', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -951,7 +951,7 @@ test('decorateRequest/decorateReply empty string', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -980,7 +980,7 @@ test('decorateRequest/decorateReply is undefined', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -1009,7 +1009,7 @@ test('decorateRequest/decorateReply is not set to a value', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down
2 changes: 1 addition & 1 deletion test/delete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ test('body - delete', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

test('shorthand - request delete', t => {
t.plan(4)
Expand Down
2 changes: 1 addition & 1 deletion test/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ test('send a falsy boolean', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

test('shorthand - request get', t => {
t.plan(4)
Expand Down
2 changes: 1 addition & 1 deletion test/head.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test('missing schema - head', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

test('shorthand - request head', t => {
t.plan(2)
Expand Down
2 changes: 1 addition & 1 deletion test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports.payloadMethod = function (method, t, isSetErrorHandler = false) {
return
}

fastify.server.unref()
t.teardown(() => { fastify.close() })

test(`${upMethod} - correctly replies`, t => {
t.plan(3)
Expand Down
2 changes: 1 addition & 1 deletion test/hooks-async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test('async hooks', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down
35 changes: 18 additions & 17 deletions test/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ test('hooks', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -263,7 +263,7 @@ test('onRequest hook should support encapsulation / 3', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -324,7 +324,7 @@ test('preHandler hook should support encapsulation / 5', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -735,7 +735,7 @@ test('onRoute hook should able to change the route url', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -920,7 +920,7 @@ test('onResponse hook should support encapsulation / 3', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -997,7 +997,7 @@ test('onSend hook should support encapsulation / 2', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -1261,7 +1261,8 @@ test('onSend hook throws', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
Expand Down Expand Up @@ -2391,7 +2392,7 @@ test('preValidation hook should support encapsulation / 3', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -2538,7 +2539,7 @@ test('preParsing hook should run before parsing and be able to modify the payloa

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down Expand Up @@ -2581,7 +2582,7 @@ test('preParsing hooks should run in the order in which they are defined', t =>

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down Expand Up @@ -2631,7 +2632,7 @@ test('preParsing hooks should support encapsulation', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'POST',
Expand Down Expand Up @@ -2752,7 +2753,7 @@ test('preParsing hook should support encapsulation / 3', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -2814,7 +2815,7 @@ test('preSerialization hook should run before serialization and be able to modif

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -2865,7 +2866,7 @@ test('preSerialization hook should be able to throw errors which are validated a

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -2899,7 +2900,7 @@ test('preSerialization hook which returned error should still run onError hooks'

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -2933,7 +2934,7 @@ test('preSerialization hooks should run in the order in which they are defined',

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down Expand Up @@ -2977,7 +2978,7 @@ test('preSerialization hooks should support encapsulation', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

sget({
method: 'GET',
Expand Down
4 changes: 2 additions & 2 deletions test/http2/closing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ t.test('http/2 request while fastify closing', t => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

t.test('return 200', t => {
const url = getUrl(fastify)
Expand Down Expand Up @@ -81,7 +81,7 @@ t.test('http/2 request while fastify closing - return503OnClosing: false', t =>

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

t.test('return 200', t => {
const url = getUrl(fastify)
Expand Down
2 changes: 1 addition & 1 deletion test/http2/constraint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test('A route supports host constraints under http2 protocol and secure connecti

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

t.test('https get request - no constrain', async (t) => {
t.plan(3)
Expand Down
2 changes: 1 addition & 1 deletion test/http2/head.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fastify.all('/', function (req, reply) {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

test('http HEAD request', async (t) => {
t.plan(1)
Expand Down
2 changes: 1 addition & 1 deletion test/http2/plain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fastify.get('/hostname', function (req, reply) {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

test('http get request', async (t) => {
t.plan(3)
Expand Down
2 changes: 1 addition & 1 deletion test/http2/secure-with-fallback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('secure with fallback', (t) => {

fastify.listen({ port: 0 }, err => {
t.error(err)
fastify.server.unref()
t.teardown(() => { fastify.close() })

t.test('https get error', async (t) => {
t.plan(1)
Expand Down

0 comments on commit a4b21f0

Please sign in to comment.