|
Bogdan Timofte
authored
6 days ago
|
1
|
import HealthKit
|
|
|
2
|
import XCTest
|
|
|
3
|
@testable import HealthProbe
|
|
|
4
|
|
|
|
5
|
final class DistributionCaptureConfigurationTests: XCTestCase {
|
|
|
6
|
func testHeartRateInitialImportUsesLargerWriteChunks() {
|
|
|
7
|
let strategy = DistributionCaptureConfiguration.initialImportStrategy(
|
|
|
8
|
for: HKQuantityTypeIdentifier.heartRate.rawValue
|
|
|
9
|
)
|
|
|
10
|
|
|
|
11
|
XCTAssertEqual(strategy.queryPageLimit, 2_000)
|
|
Bogdan Timofte
authored
5 days ago
|
12
|
XCTAssertEqual(strategy.initialWriteChunkSize, 5_000)
|
|
Bogdan Timofte
authored
6 days ago
|
13
|
XCTAssertEqual(strategy.initialArchiveFlushSampleLimit, 10_000)
|
|
Bogdan Timofte
authored
6 days ago
|
14
|
XCTAssertEqual(strategy.minimumWriteChunkSize, 500)
|
|
|
15
|
XCTAssertEqual(strategy.slowBatchThresholdSeconds, 2.5)
|
|
|
16
|
XCTAssertEqual(strategy.severeBatchThresholdSeconds, 6)
|
|
|
17
|
}
|
|
|
18
|
|
|
|
19
|
func testHeartRateWriteChunkCanBackOffOnSlowDevices() {
|
|
|
20
|
let strategy = DistributionCaptureConfiguration.initialImportStrategy(
|
|
|
21
|
for: HKQuantityTypeIdentifier.heartRate.rawValue
|
|
|
22
|
)
|
|
|
23
|
var state = strategy.makePersistenceState()
|
|
|
24
|
|
|
|
25
|
state.registerBatchDuration(strategy.severeBatchThresholdSeconds)
|
|
|
26
|
|
|
Bogdan Timofte
authored
5 days ago
|
27
|
XCTAssertEqual(state.currentWriteChunkSize, 2_500)
|
|
Bogdan Timofte
authored
6 days ago
|
28
|
|
|
|
29
|
state.registerBatchDuration(strategy.severeBatchThresholdSeconds)
|
|
|
30
|
|
|
Bogdan Timofte
authored
5 days ago
|
31
|
XCTAssertEqual(state.currentWriteChunkSize, 1_250)
|
|
Bogdan Timofte
authored
6 days ago
|
32
|
}
|
|
|
33
|
}
|