Skip to content

Commit 86d019d

Browse files
committed
Fix tests
1 parent e2fe8e8 commit 86d019d

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

DatadogCore/Tests/Datadog/Tracing/TracingURLSessionHandlerTests.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,20 @@ class TracingURLSessionHandlerTests: XCTestCase {
227227
)
228228
let message = FeatureMessage.context(fakeContext)
229229
_ = handler.contextReceiver.receive(message: message, from: core)
230+
let networkContextSessionId = "abcdef01-2345-6789-abcd-ef0123456789"
230231
let (modifiedRequest, _, _) = handler.modify(
231232
request: request,
232233
headerTypes: [.datadog, .tracecontext, .b3, .b3multi],
233234
networkContext: NetworkContext(
234235
rumContext: .init(
235236
applicationID: .mockRandom(),
236-
sessionID: "abcdef01-2345-6789-abcd-ef0123456789"
237+
sessionID: networkContextSessionId
237238
)
238239
)
239240
)
240-
241-
XCTAssertEqual(
242-
modifiedRequest.allHTTPHeaderFields,
241+
let resultingHeaders = try XCTUnwrap(modifiedRequest.allHTTPHeaderFields)
242+
DDAssertDictionariesEqual(
243+
resultingHeaders,
243244
[
244245
"traceparent": "00-000000000000000a0000000000000064-0000000000000064-01",
245246
"X-B3-SpanId": "0000000000000064",
@@ -248,7 +249,7 @@ class TracingURLSessionHandlerTests: XCTestCase {
248249
"b3": "000000000000000a0000000000000064-0000000000000064-1",
249250
"x-datadog-trace-id": "100",
250251
"x-datadog-tags": "_dd.p.tid=a,_dd.p.dm=-1",
251-
"baggage": "session.id=\(fakeSessionId)",
252+
"baggage": "session.id=\(networkContextSessionId)",
252253
"tracestate": "dd=p:0000000000000064;s:1;t.dm:-1",
253254
"x-datadog-parent-id": "100",
254255
"x-datadog-sampling-priority": "1"

DatadogTrace/Tests/TracingURLSessionHandlerTests.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ class TracingURLSessionHandlerTests: XCTestCase {
851851
contextReceiver: ContextMessageReceiver(),
852852
samplingRate: .maxSampleRate,
853853
firstPartyHosts: .init(),
854-
traceContextInjection: .all
854+
traceContextInjection: .all,
855+
telemetry: TelemetryMock()
855856
)
856857

857858
var request = URLRequest.mockWith(url: "https://www.example.com")
@@ -886,7 +887,8 @@ class TracingURLSessionHandlerTests: XCTestCase {
886887
contextReceiver: ContextMessageReceiver(),
887888
samplingRate: .maxSampleRate,
888889
firstPartyHosts: .init(),
889-
traceContextInjection: .all
890+
traceContextInjection: .all,
891+
telemetry: TelemetryMock()
890892
)
891893

892894
var request = URLRequest.mockWith(url: "https://www.example.com")
@@ -921,7 +923,8 @@ class TracingURLSessionHandlerTests: XCTestCase {
921923
contextReceiver: ContextMessageReceiver(),
922924
samplingRate: .maxSampleRate,
923925
firstPartyHosts: .init(),
924-
traceContextInjection: .all
926+
traceContextInjection: .all,
927+
telemetry: TelemetryMock()
925928
)
926929

927930
var request = URLRequest.mockWith(url: "https://www.example.com")
@@ -972,7 +975,8 @@ class TracingURLSessionHandlerTests: XCTestCase {
972975
contextReceiver: ContextMessageReceiver(),
973976
samplingRate: .maxSampleRate,
974977
firstPartyHosts: .init(),
975-
traceContextInjection: .all
978+
traceContextInjection: .all,
979+
telemetry: TelemetryMock()
976980
)
977981

978982
let request = URLRequest.mockWith(url: "https://www.example.com")

0 commit comments

Comments
 (0)