Skip to content

Commit c641645

Browse files
authored
test: Fixed fastify assertions around span kind while running security agent (#2983)
1 parent 697b17e commit c641645

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

test/lib/custom-assertions/assert-span-kind.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function assertSpanKind({ agent, segments, assert = require('no
2828
if (!span) {
2929
assert.fail(`Could not find span: ${segment.name}`)
3030
}
31-
assert.equal(span.intrinsics['span.kind'], segment.kind)
31+
assert.equal(span.intrinsics['span.kind'], segment.kind, `${segment.name} span kind differs. expected: ${segment.kind}, got: ${span.intrinsics['span.kind']}`)
3232
})
3333
} else {
3434
assert.fail('Custom assertion must either pass in an array of span kinds or a collection of segment names to span kind')

test/versioned/fastify/naming-common.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,7 @@ module.exports = async function runTests(t, getExpectedSegments) {
4444
}
4545

4646
assertSegments(transaction.trace, transaction.trace.root, expectedSegments)
47-
const flattenedSegments = expectedSegments[1].reduce((segments, segment) => {
48-
if (Array.isArray(segment)) {
49-
segments.push(...segment.map((s) => {
50-
return {
51-
name: s,
52-
kind: 'internal'
53-
}
54-
}))
55-
} else {
56-
segments.push({ name: segment, kind: 'internal' })
57-
}
58-
59-
return segments
60-
}, [])
47+
const [,...flattenedSegments] = expectedSegments.flat(3).map((name) => ({ name, kind: 'internal' }))
6148
assertSpanKind({
6249
agent,
6350
segments: [

0 commit comments

Comments
 (0)