Fix formatting in tests

This commit is contained in:
Natik Gadzhi 2023-06-22 21:40:11 -07:00
parent e0ce4e8da3
commit d0bd9aac07
No known key found for this signature in database
GPG Key ID: E6387D41B53DEE06
1 changed files with 8 additions and 10 deletions

View File

@ -95,32 +95,30 @@ class MetricsExtensionsTests: XCTestCase {
XCTAssertEqual(UInt64(testTimer.values.first!), end.uptimeNanoseconds - start.uptimeNanoseconds, "expected value to match") XCTAssertEqual(UInt64(testTimer.values.first!), end.uptimeNanoseconds - start.uptimeNanoseconds, "expected value to match")
XCTAssertEqual(metrics.timers.count, 1, "timer should have been stored") XCTAssertEqual(metrics.timers.count, 1, "timer should have been stored")
} }
func testTimerDuration() throws { func testTimerDuration() throws {
#if swift(>=5.7) #if swift(>=5.7)
guard #available(iOS 16, macOS 13, tvOS 15, watchOS 8, *) else { guard #available(iOS 16, macOS 13, tvOS 15, watchOS 8, *) else {
return return
} }
let metrics = TestMetrics() let metrics = TestMetrics()
MetricsSystem.bootstrapInternal(metrics) MetricsSystem.bootstrapInternal(metrics)
let name = "timer-\(UUID().uuidString)" let name = "timer-\(UUID().uuidString)"
let duration = Duration(secondsComponent: 3, attosecondsComponent: 123000000000000000) let duration = Duration(secondsComponent: 3, attosecondsComponent: 123_000_000_000_000_000)
let durationInNanoseconds = duration.components.seconds * 1_000_000_000 + duration.components.attoseconds / 1_000_000_000 let durationInNanoseconds = duration.components.seconds * 1_000_000_000 + duration.components.attoseconds / 1_000_000_000
let timer = Timer(label: name) let timer = Timer(label: name)
timer.record(duration) timer.record(duration)
let testTimer = try metrics.expectTimer(timer) let testTimer = try metrics.expectTimer(timer)
XCTAssertEqual(testTimer.values.count, 1, "expected number of entries to match") XCTAssertEqual(testTimer.values.count, 1, "expected number of entries to match")
XCTAssertEqual(testTimer.values.first, durationInNanoseconds, "expected value to match") XCTAssertEqual(testTimer.values.first, durationInNanoseconds, "expected value to match")
XCTAssertEqual(metrics.timers.count, 1, "timer should have been stored") XCTAssertEqual(metrics.timers.count, 1, "timer should have been stored")
#endif #endif
} }
func testTimerUnits() throws { func testTimerUnits() throws {
let metrics = TestMetrics() let metrics = TestMetrics()
MetricsSystem.bootstrapInternal(metrics) MetricsSystem.bootstrapInternal(metrics)