Skip to content

Commit 6e59a87

Browse files
committed
test for propagation context
1 parent db9d8a0 commit 6e59a87

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@testable import Sentry
2+
import XCTest
3+
4+
class SentryPropagationContextTests: XCTestCase {
5+
6+
func testInitWithTraceIdSpanId() {
7+
let traceId = SentryId()
8+
let spanId = SpanId()
9+
10+
let context = SentryPropagationContext(traceId: traceId, spanId: spanId)
11+
12+
XCTAssertEqual(traceId, context.traceId)
13+
XCTAssertEqual(spanId, context.spanId)
14+
}
15+
16+
func testTraceContextForEvent() {
17+
let traceId = SentryId()
18+
let spanId = SpanId()
19+
20+
let context = SentryPropagationContext(traceId: traceId, spanId: spanId)
21+
22+
let traceContext = context.traceContextForEvent()
23+
24+
XCTAssertEqual(traceContext.count, 2)
25+
XCTAssertEqual(traceContext["trace_id"], traceId.sentryIdString)
26+
XCTAssertEqual(traceContext["span_id"], spanId.sentrySpanIdString)
27+
}
28+
29+
func testTraceHeader() {
30+
let traceId = SentryId()
31+
let spanId = SpanId()
32+
33+
let context = SentryPropagationContext(traceId: traceId, spanId: spanId)
34+
35+
let traceHeader = context.traceHeader
36+
37+
XCTAssertNotNil(traceHeader)
38+
XCTAssertEqual(traceHeader.traceId, traceId)
39+
XCTAssertEqual(traceHeader.spanId, spanId)
40+
}
41+
}

0 commit comments

Comments
 (0)