Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove most usage of get-port for plugin tests #4429

Merged
merged 3 commits into from
Jun 25, 2024
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
9 changes: 3 additions & 6 deletions packages/datadog-instrumentations/test/body-parser.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const getPort = require('get-port')
const dc = require('dc-polyfill')
const axios = require('axios')
const agent = require('../../dd-trace/test/plugins/agent')
Expand All @@ -22,11 +21,9 @@ withVersions('body-parser', 'body-parser', version => {
middlewareProcessBodyStub()
res.end('DONE')
})
getPort().then(newPort => {
port = newPort
server = app.listen(port, () => {
done()
})
server = app.listen(0, () => {
port = server.address().port
done()
})
})
beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const { assert } = require('chai')
const getPort = require('get-port')
const dc = require('dc-polyfill')
const axios = require('axios')
const agent = require('../../dd-trace/test/plugins/agent')
Expand All @@ -23,11 +22,9 @@ withVersions('cookie-parser', 'cookie-parser', version => {
middlewareProcessCookieStub()
res.end('DONE')
})
getPort().then(newPort => {
port = newPort
server = app.listen(port, () => {
done()
})
server = app.listen(0, () => {
port = server.address().port
done()
})
})
beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const agent = require('../../dd-trace/test/plugins/agent')
const getPort = require('get-port')
const { channel } = require('dc-polyfill')
const axios = require('axios')
describe('express-mongo-sanitize', () => {
Expand All @@ -25,11 +24,9 @@ describe('express-mongo-sanitize', () => {
res.end()
})

getPort().then(newPort => {
port = newPort
server = app.listen(port, () => {
done()
})
server = app.listen(0, () => {
port = server.address().port
done()
})
})

Expand Down
9 changes: 3 additions & 6 deletions packages/datadog-instrumentations/test/express.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const agent = require('../../dd-trace/test/plugins/agent')
const getPort = require('get-port')
const axios = require('axios')
const dc = require('dc-polyfill')

Expand All @@ -20,11 +19,9 @@ withVersions('express', 'express', version => {
requestBody()
res.end('DONE')
})
getPort().then(newPort => {
port = newPort
server = app.listen(port, () => {
done()
})
server = app.listen(0, () => {
port = server.address().port
done()
})
})
beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const agent = require('../../dd-trace/test/plugins/agent')
const getPort = require('get-port')
const axios = require('axios')
const dc = require('dc-polyfill')

Expand Down Expand Up @@ -70,11 +69,9 @@ withVersions('passport-http', 'passport-http', version => {
subscriberStub(arguments[0])
})

getPort().then(newPort => {
port = newPort
server = app.listen(port, () => {
done()
})
server = app.listen(0, () => {
port = server.address().port
done()
})
})
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const agent = require('../../dd-trace/test/plugins/agent')
const getPort = require('get-port')
const axios = require('axios')
const dc = require('dc-polyfill')

Expand Down Expand Up @@ -71,11 +70,9 @@ withVersions('passport-local', 'passport-local', version => {
subscriberStub(arguments[0])
})

getPort().then(newPort => {
port = newPort
server = app.listen(port, () => {
done()
})
server = app.listen(0, () => {
port = server.address().port
done()
})
})
beforeEach(() => {
Expand Down
13 changes: 7 additions & 6 deletions packages/datadog-plugin-apollo/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const agent = require('../../dd-trace/test/plugins/agent.js')
const { ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants.js')
const { expectedSchema, rawExpectedSchema } = require('./naming.js')
const axios = require('axios')
const getPort = require('get-port')

const accounts = require('./fixtures.js')

Expand Down Expand Up @@ -86,13 +85,15 @@ describe('Plugin', () => {
gateway: setupGateway(),
subscriptions: false // Disable subscriptions (not supported with Apollo Gateway)
})
getPort().then(newPort => {
port = newPort
startStandaloneServer(server, {
listen: { port }
}).then(() => {})

return startStandaloneServer(server, {
listen: { port: 0 }
}).then(({ url }) => {
port = new URL(url).port
})
})

before(() => {
return agent.load('apollo')
})

Expand Down
Loading
Loading