-
Notifications
You must be signed in to change notification settings - Fork 113
/
RUMMonitorConfigurationTests.swift
60 lines (50 loc) · 2.03 KB
/
RUMMonitorConfigurationTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/
import XCTest
import TestUtilities
import DatadogInternal
@testable import DatadogRUM
class RUMMonitorConfigurationTests: XCTestCase {
private let userIno: UserInfo = .mockAny()
private let networkConnectionInfo: NetworkConnectionInfo = .mockAny()
private let carrierInfo: CarrierInfo = .mockAny()
func testRUMMonitorConfiguration() throws {
let expectation = expectation(description: "open feature scope")
let core = DatadogCoreProxy(
context: .mockWith(
service: "service-name",
env: "tests",
version: "1.2.3",
sdkVersion: "3.4.5",
userInfo: userIno,
networkConnectionInfo: networkConnectionInfo,
carrierInfo: carrierInfo
)
)
defer { core.flushAndTearDown() }
RUM.enable(
with: .init(
applicationID: "rum-123",
sessionSampleRate: 42.5
),
in: core
)
let monitor = RUMMonitor.shared(in: core).dd
let dependencies = monitor.scopes.dependencies
monitor.featureScope.eventWriteContext { context, _ in
DDAssertReflectionEqual(context.userInfo, self.userIno)
XCTAssertEqual(context.networkConnectionInfo, self.networkConnectionInfo)
XCTAssertEqual(context.carrierInfo, self.carrierInfo)
XCTAssertEqual(context.service, "service-name")
XCTAssertEqual(context.version, "1.2.3")
XCTAssertEqual(context.sdkVersion, "3.4.5")
expectation.fulfill()
}
XCTAssertEqual(dependencies.sessionSampler.samplingRate, 42.5)
XCTAssertEqual(monitor.scopes.context.rumApplicationID, "rum-123")
waitForExpectations(timeout: 0.5)
}
}