Skip to content

Commit 4738c43

Browse files
committed
Fix callstack.test.js
1 parent 9b2885b commit 4738c43

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

test/context/callstack.test.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ test(`span and spanEvent call stack`, async (t) => {
3131
t.true(response.status == 200)
3232
t.equal(agent.traceContext.currentTraceObject(), trace, 'current trace is current asyncId trace object')
3333
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList.length, 2, 'spanEventList length')
34-
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[0].annotations[0].key, 12, 'APIDesc key')
35-
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[0].annotations[0].value, 'GET', 'APIDesc stringValue')
36-
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[0].annotations[1].key, 40, 'HTTP.URL key')
37-
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[0].annotations[1].value, 'github.com/', 'HTTP.URL stringValue')
38-
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[0].annotations[2].key, 46, 'HTTP.status.code')
39-
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[0].annotations[2].value, 200, 'HTTP.status.code stringValue')
34+
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[1].annotations[0].key, 12, 'APIDesc key')
35+
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[1].annotations[0].value, 'GET', 'APIDesc stringValue')
36+
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[1].annotations[1].key, 40, 'HTTP.URL key')
37+
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[1].annotations[1].value, 'github.com/', 'HTTP.URL stringValue')
38+
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[1].annotations[2].key, 46, 'HTTP.status.code')
39+
t.equal(agent.dataSender.mockSpanChunks[0].spanEventList[1].annotations[2].value, 200, 'HTTP.status.code stringValue')
4040
agent.completeTraceObject(trace)
4141
})
4242
})
@@ -96,7 +96,18 @@ test(`fix express call stack depth`, async (t) => {
9696
t.equal(actualSpanEvent.depth, 1, 'use(urlencodedParser) depth')
9797
t.equal(actualSpanEvent.serviceType, ServiceTypeCode.express, 'use(urlencodedParser) serviceType')
9898

99+
actualBuilder = new MethodDescriptorBuilder('get')
100+
.setClassName('proto')
101+
.setLineNumber(62)
102+
.setFileName('callstack.test.js')
103+
actualMethodDescriptor = apiMetaService.cacheApiWithBuilder(actualBuilder)
99104
actualSpanEvent = agent.dataSender.mockSpan.spanEventList[2]
105+
t.equal(actualSpanEvent.apiId, actualMethodDescriptor.apiId, 'get(/) apiId')
106+
t.equal(actualSpanEvent.sequence, 2, 'get(/) sequence')
107+
t.equal(actualSpanEvent.depth, 1, 'get(/) depth')
108+
t.equal(actualSpanEvent.serviceType, ServiceTypeCode.express, 'get(/) serviceType')
109+
110+
actualSpanEvent = agent.dataSender.mockSpan.spanEventList[3]
100111
t.equal(actualSpanEvent.apiId, 0, 'await axios.get(`https://naver.com`) apiId')
101112
t.equal(actualSpanEvent.sequence, 3, 'await axios.get(`https://naver.com`) sequence')
102113
t.equal(actualSpanEvent.depth, 2, 'await axios.get(`https://naver.com`) depth')
@@ -166,7 +177,7 @@ test('fix express call stack depth without callSite', async (t) => {
166177
t.equal(actualSpanEvent.depth, 1, 'use(urlencodedParser) depth')
167178
t.equal(actualSpanEvent.serviceType, ServiceTypeCode.express, 'use(urlencodedParser) serviceType')
168179

169-
actualSpanEvent = agent.dataSender.mockSpan.spanEventList[2]
180+
actualSpanEvent = agent.dataSender.mockSpan.spanEventList[3]
170181
t.equal(actualSpanEvent.apiId, 0, 'await axios.get(`https://naver.com`) apiId')
171182
t.equal(actualSpanEvent.sequence, 3, 'await axios.get(`https://naver.com`) sequence')
172183
t.equal(actualSpanEvent.depth, 2, 'await axios.get(`https://naver.com`) depth')

0 commit comments

Comments
 (0)