|
8 | 8 | const test = require('node:test') |
9 | 9 | const assert = require('node:assert') |
10 | 10 | const os = require('node:os') |
11 | | -const { Writable } = require('node:stream'); |
| 11 | +const { Writable } = require('node:stream') |
12 | 12 |
|
13 | 13 | const { tspl } = require('@matteo.collina/tspl') |
14 | 14 | const helper = require('../../lib/agent_helper') |
@@ -273,8 +273,6 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
273 | 273 |
|
274 | 274 | assert.ok(headers.traceparent) |
275 | 275 | assert.ok(headers.tracestate) |
276 | | - |
277 | | - callback(null, validResponse) |
278 | 276 | }) |
279 | 277 |
|
280 | 278 | const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
@@ -437,7 +435,7 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
437 | 435 | } |
438 | 436 | }) |
439 | 437 |
|
440 | | - /// TODO: make sure the agent can capture HTTP statusCode from the stream metadata. |
| 438 | + /// TODO: make sure the agent can capture HTTP statusCode from the stream metadata. |
441 | 439 | // await t.test('should capture status code', (t, end) => { |
442 | 440 | // const { agent, awsLambda, stubResponseStream, stubContext } = t.nr |
443 | 441 | // agent.on('transactionFinished', confirmAgentAttribute) |
@@ -541,7 +539,7 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
541 | 539 | const chunks = ['no headers 1', 'no headers 2', 'no headers 3'] |
542 | 540 | await writeStreamResponse(chunks, responseStream, 500) |
543 | 541 | responseStream.end() |
544 | | - }); |
| 542 | + }) |
545 | 543 |
|
546 | 544 | const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
547 | 545 |
|
@@ -1190,79 +1188,79 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
1190 | 1188 | } |
1191 | 1189 | }) |
1192 | 1190 |
|
1193 | | - await t.test('when callback used', async (t) => { |
1194 | | - helper.unloadAgent(t.nr.agent) |
| 1191 | + // await t.test('when callback used', async (t) => { |
| 1192 | + // helper.unloadAgent(t.nr.agent) |
1195 | 1193 |
|
1196 | | - await t.test('should end appropriately', (t, end) => { |
1197 | | - const { agent, awsLambda, stubEvent, stubContext } = t.nr |
1198 | | - let transaction |
| 1194 | + // await t.test('should end appropriately', (t, end) => { |
| 1195 | + // const { agent, awsLambda, stubEvent, stubContext } = t.nr |
| 1196 | + // let transaction |
1199 | 1197 |
|
1200 | | - const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
1201 | | - transaction = agent.tracer.getTransaction() |
1202 | | - callback(null, 'worked') |
1203 | | - }) |
| 1198 | + // const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
| 1199 | + // transaction = agent.tracer.getTransaction() |
| 1200 | + // callback(null, 'worked') |
| 1201 | + // }) |
1204 | 1202 |
|
1205 | | - const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
| 1203 | + // const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
1206 | 1204 |
|
1207 | | - wrappedHandler(stubEvent, stubContext, function confirmEndCallback() { |
1208 | | - assert.equal(transaction.isActive(), false) |
| 1205 | + // wrappedHandler(stubEvent, stubContext, function confirmEndCallback() { |
| 1206 | + // assert.equal(transaction.isActive(), false) |
1209 | 1207 |
|
1210 | | - const currentTransaction = agent.tracer.getTransaction() |
1211 | | - assert.equal(currentTransaction, null) |
1212 | | - end() |
1213 | | - }) |
1214 | | - }) |
| 1208 | + // const currentTransaction = agent.tracer.getTransaction() |
| 1209 | + // assert.equal(currentTransaction, null) |
| 1210 | + // end() |
| 1211 | + // }) |
| 1212 | + // }) |
1215 | 1213 |
|
1216 | | - await t.test('should notice errors', (t, end) => { |
1217 | | - const { agent, awsLambda, error, stubEvent, stubResponseStream, stubContext } = t.nr |
1218 | | - agent.on('harvestStarted', confirmErrorCapture) |
| 1214 | + // await t.test('should notice errors', (t, end) => { |
| 1215 | + // const { agent, awsLambda, error, stubEvent, stubResponseStream, stubContext } = t.nr |
| 1216 | + // agent.on('harvestStarted', confirmErrorCapture) |
1219 | 1217 |
|
1220 | | - const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
1221 | | - callback(error, 'failed') |
1222 | | - }) |
| 1218 | + // const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
| 1219 | + // callback(error, 'failed') |
| 1220 | + // }) |
1223 | 1221 |
|
1224 | | - const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
| 1222 | + // const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
1225 | 1223 |
|
1226 | | - wrappedHandler(stubEvent, stubResponseStream, stubContext) |
| 1224 | + // wrappedHandler(stubEvent, stubResponseStream, stubContext) |
1227 | 1225 |
|
1228 | | - function confirmErrorCapture() { |
1229 | | - assert.equal(agent.errors.traceAggregator.errors.length, 1) |
1230 | | - const noticedError = agent.errors.traceAggregator.errors[0] |
1231 | | - assert.equal(noticedError[1], expectedBgTransactionName) |
1232 | | - assert.equal(noticedError[2], errorMessage) |
1233 | | - assert.equal(noticedError[3], 'SyntaxError') |
1234 | | - } |
| 1226 | + // function confirmErrorCapture() { |
| 1227 | + // assert.equal(agent.errors.traceAggregator.errors.length, 1) |
| 1228 | + // const noticedError = agent.errors.traceAggregator.errors[0] |
| 1229 | + // assert.equal(noticedError[1], expectedBgTransactionName) |
| 1230 | + // assert.equal(noticedError[2], errorMessage) |
| 1231 | + // assert.equal(noticedError[3], 'SyntaxError') |
| 1232 | + // } |
1235 | 1233 |
|
1236 | | - end() |
1237 | | - }) |
| 1234 | + // end() |
| 1235 | + // }) |
1238 | 1236 |
|
1239 | | - await t.test('should notice string errors', (t, end) => { |
1240 | | - const { agent, awsLambda, stubEvent, stubResponseStream, stubContext } = t.nr |
1241 | | - agent.on('harvestStarted', confirmErrorCapture) |
| 1237 | + // await t.test('should notice string errors', (t, end) => { |
| 1238 | + // const { agent, awsLambda, stubEvent, stubResponseStream, stubContext } = t.nr |
| 1239 | + // agent.on('harvestStarted', confirmErrorCapture) |
1242 | 1240 |
|
1243 | | - const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
1244 | | - // eslint-disable-next-line n/no-callback-literal |
1245 | | - callback('failed') |
1246 | | - }) |
| 1241 | + // const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
| 1242 | + // // eslint-disable-next-line n/no-callback-literal |
| 1243 | + // callback('failed') |
| 1244 | + // }) |
1247 | 1245 |
|
1248 | | - const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
| 1246 | + // const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
1249 | 1247 |
|
1250 | | - wrappedHandler(stubEvent, stubResponseStream, stubContext) |
| 1248 | + // wrappedHandler(stubEvent, stubResponseStream, stubContext) |
1251 | 1249 |
|
1252 | | - function confirmErrorCapture() { |
1253 | | - assert.equal(agent.errors.traceAggregator.errors.length, 1) |
1254 | | - const noticedError = agent.errors.traceAggregator.errors[0] |
1255 | | - assert.equal(noticedError[1], expectedBgTransactionName) |
1256 | | - assert.equal(noticedError[2], 'failed') |
1257 | | - assert.equal(noticedError[3], 'Error') |
| 1250 | + // function confirmErrorCapture() { |
| 1251 | + // assert.equal(agent.errors.traceAggregator.errors.length, 1) |
| 1252 | + // const noticedError = agent.errors.traceAggregator.errors[0] |
| 1253 | + // assert.equal(noticedError[1], expectedBgTransactionName) |
| 1254 | + // assert.equal(noticedError[2], 'failed') |
| 1255 | + // assert.equal(noticedError[3], 'Error') |
1258 | 1256 |
|
1259 | | - const data = noticedError[4] |
1260 | | - assert.ok(data.stack_trace) |
1261 | | - } |
| 1257 | + // const data = noticedError[4] |
| 1258 | + // assert.ok(data.stack_trace) |
| 1259 | + // } |
1262 | 1260 |
|
1263 | | - end() |
1264 | | - }) |
1265 | | - }) |
| 1261 | + // end() |
| 1262 | + // }) |
| 1263 | + // }) |
1266 | 1264 |
|
1267 | 1265 | await test('when context.done used', async (t) => { |
1268 | 1266 | helper.unloadAgent(t.nr.agent) |
@@ -1328,7 +1326,7 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
1328 | 1326 | }) |
1329 | 1327 |
|
1330 | 1328 | const handler = lambdaBuiltIns.streamifyResponse(async (event, responseStream, context) => { |
1331 | | - context.done(error, 'failed') |
| 1329 | + context.done('failed') |
1332 | 1330 | }) |
1333 | 1331 |
|
1334 | 1332 | const wrappedHandler = awsLambda.patchLambdaHandler(handler) |
@@ -1387,7 +1385,6 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
1387 | 1385 | context.fail() |
1388 | 1386 | }) |
1389 | 1387 |
|
1390 | | - |
1391 | 1388 | wrappedHandler(stubEvent, stubResponseStream, stubContext) |
1392 | 1389 | }) |
1393 | 1390 |
|
@@ -1694,8 +1691,6 @@ test('AwsLambda.patchLambdaHandler', async (t) => { |
1694 | 1691 | assert.equal(transaction.getFullName(), expectedBgTransactionName) |
1695 | 1692 | assert.ok(transaction.isActive()) |
1696 | 1693 |
|
1697 | | - cb() |
1698 | | - |
1699 | 1694 | assert.equal(transaction.isActive(), false) |
1700 | 1695 | return resolve('hello') |
1701 | 1696 | }) |
|
0 commit comments