Skip to content

Commit 5ec1368

Browse files
authored
Revert "test: Updated koa-router to tests to handle bug fixes from 13.0.1 (newrelic#2578)"
This reverts commit 23e979c.
1 parent 343aea6 commit 5ec1368

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

test/versioned/koa/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"samples": 5
3535
},
3636
"koa-router": {
37-
"versions": ">=11.0.2",
37+
"versions": ">=11.0.2 && <13.0.0",
3838
"samples": 5
3939
}
4040
},
@@ -53,7 +53,7 @@
5353
"samples": 5
5454
},
5555
"@koa/router": {
56-
"versions": ">=11.0.2",
56+
"versions": ">=11.0.2 && <13.0.0",
5757
"samples": 5
5858
}
5959
},

test/versioned/koa/router-common.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = (pkg) => {
4545
}
4646

4747
function tearDown(t) {
48-
t.context?.server?.close()
48+
t.context.server.close()
4949
helper.unloadAgent(t.context.agent)
5050
}
5151

@@ -148,22 +148,18 @@ module.exports = (pkg) => {
148148

149149
t.test('should name and produce segments for matched wildcard path', (t) => {
150150
const { agent, router, app } = t.context
151-
let path = '(.*)'
152-
if (semver.gte(pkgVersion, '13.0.1')) {
153-
path = '{*any}'
154-
}
155-
router.get(`/:first/${path}`, function firstMiddleware(ctx) {
151+
router.get('/:first/(.*)', function firstMiddleware(ctx) {
156152
ctx.body = 'first'
157153
})
158154
app.use(router.routes())
159155
agent.on('transactionFinished', (tx) => {
160156
t.assertSegments(tx.trace.root, [
161-
`WebTransaction/WebFrameworkUri/Koa/GET//:first/${path}`,
162-
['Koa/Router: /', [`Nodejs/Middleware/Koa/firstMiddleware//:first/${path}`]]
157+
'WebTransaction/WebFrameworkUri/Koa/GET//:first/(.*)',
158+
['Koa/Router: /', ['Nodejs/Middleware/Koa/firstMiddleware//:first/(.*)']]
163159
])
164160
t.equal(
165161
tx.name,
166-
`WebTransaction/WebFrameworkUri/Koa/GET//:first/${path}`,
162+
'WebTransaction/WebFrameworkUri/Koa/GET//:first/(.*)',
167163
'transaction should be named after the matched regex path'
168164
)
169165
t.end()
@@ -346,21 +342,20 @@ module.exports = (pkg) => {
346342
router.get('/:second', function terminalMiddleware(ctx) {
347343
ctx.body = ' second'
348344
})
349-
350-
const segmentTree = semver.gte(pkgVersion, '13.0.1')
351-
? ['Nodejs/Middleware/Koa/terminalMiddleware//:second']
352-
: [
353-
'Nodejs/Middleware/Koa/secondMiddleware//:first',
354-
[
355-
'Nodejs/Middleware/Koa/secondMiddleware//:second',
356-
['Nodejs/Middleware/Koa/terminalMiddleware//:second']
357-
]
358-
]
359345
app.use(router.routes())
360346
agent.on('transactionFinished', (tx) => {
361347
t.assertSegments(tx.trace.root, [
362348
'WebTransaction/WebFrameworkUri/Koa/GET//:second',
363-
['Koa/Router: /', segmentTree]
349+
[
350+
'Koa/Router: /',
351+
[
352+
'Nodejs/Middleware/Koa/secondMiddleware//:first',
353+
[
354+
'Nodejs/Middleware/Koa/secondMiddleware//:second',
355+
['Nodejs/Middleware/Koa/terminalMiddleware//:second']
356+
]
357+
]
358+
]
364359
])
365360
t.equal(
366361
tx.name,

0 commit comments

Comments
 (0)