Skip to content

Commit 78b6238

Browse files
authored
Use UUID instead of NSUUID in MetricsTests (#126)
1 parent a79936f commit 78b6238

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

Sources/MetricsTestKit/TestMetrics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public final class TestCounter: TestMetric, CounterHandler, Equatable {
243243
private var values = [(Date, Int64)]()
244244

245245
init(label: String, dimensions: [(String, String)]) {
246-
self.id = NSUUID().uuidString
246+
self.id = UUID().uuidString
247247
self.label = label
248248
self.dimensions = dimensions
249249
}
@@ -297,7 +297,7 @@ public final class TestRecorder: TestMetric, RecorderHandler, Equatable {
297297
private var values = [(Date, Double)]()
298298

299299
init(label: String, dimensions: [(String, String)], aggregate: Bool) {
300-
self.id = NSUUID().uuidString
300+
self.id = UUID().uuidString
301301
self.label = label
302302
self.dimensions = dimensions
303303
self.aggregate = aggregate
@@ -345,7 +345,7 @@ public final class TestTimer: TestMetric, TimerHandler, Equatable {
345345
private var _values = [(Date, Int64)]()
346346

347347
init(label: String, dimensions: [(String, String)]) {
348-
self.id = NSUUID().uuidString
348+
self.id = UUID().uuidString
349349
self.label = label
350350
self.displayUnit = nil
351351
self.dimensions = dimensions

Tests/MetricsTests/CoreMetricsTests.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MetricsTests: XCTestCase {
2121
let metrics = TestMetrics()
2222
MetricsSystem.bootstrapInternal(metrics)
2323
let group = DispatchGroup()
24-
let name = "counter-\(NSUUID().uuidString)"
24+
let name = "counter-\(UUID().uuidString)"
2525
let counter = Counter(label: name)
2626
let testCounter = counter._handler as! TestCounter
2727
let total = Int.random(in: 500 ... 1000)
@@ -43,7 +43,7 @@ class MetricsTests: XCTestCase {
4343
let metrics = TestMetrics()
4444
MetricsSystem.bootstrapInternal(metrics)
4545
// run the test
46-
let name = "counter-\(NSUUID().uuidString)"
46+
let name = "counter-\(UUID().uuidString)"
4747
let value = Int.random(in: Int.min ... Int.max)
4848
Counter(label: name).increment(by: value)
4949
let counter = metrics.counters[name] as! TestCounter
@@ -150,7 +150,7 @@ class MetricsTests: XCTestCase {
150150
let metrics = TestMetrics()
151151
MetricsSystem.bootstrapInternal(metrics)
152152
let group = DispatchGroup()
153-
let name = "recorder-\(NSUUID().uuidString)"
153+
let name = "recorder-\(UUID().uuidString)"
154154
let recorder = Recorder(label: name)
155155
let testRecorder = recorder._handler as! TestRecorder
156156
let total = Int.random(in: 500 ... 1000)
@@ -202,7 +202,7 @@ class MetricsTests: XCTestCase {
202202
let metrics = TestMetrics()
203203
MetricsSystem.bootstrapInternal(metrics)
204204
// run the test
205-
let name = "recorder-\(NSUUID().uuidString)"
205+
let name = "recorder-\(UUID().uuidString)"
206206
let value = Double.random(in: Double(Int.min) ... Double(Int.max))
207207
Recorder(label: name).record(value)
208208
let recorder = metrics.recorders[name] as! TestRecorder
@@ -215,7 +215,7 @@ class MetricsTests: XCTestCase {
215215
let metrics = TestMetrics()
216216
MetricsSystem.bootstrapInternal(metrics)
217217
let group = DispatchGroup()
218-
let name = "timer-\(NSUUID().uuidString)"
218+
let name = "timer-\(UUID().uuidString)"
219219
let timer = Timer(label: name)
220220
let testTimer = timer._handler as! TestTimer
221221
let total = Int.random(in: 500 ... 1000)
@@ -235,7 +235,7 @@ class MetricsTests: XCTestCase {
235235
let metrics = TestMetrics()
236236
MetricsSystem.bootstrapInternal(metrics)
237237
// run the test
238-
let name = "timer-\(NSUUID().uuidString)"
238+
let name = "timer-\(UUID().uuidString)"
239239
let value = Int64.random(in: Int64.min ... Int64.max)
240240
Timer(label: name).recordNanoseconds(value)
241241
let timer = metrics.timers[name] as! TestTimer
@@ -339,7 +339,7 @@ class MetricsTests: XCTestCase {
339339
let metrics = TestMetrics()
340340
MetricsSystem.bootstrapInternal(metrics)
341341
// run the test
342-
let name = "gauge-\(NSUUID().uuidString)"
342+
let name = "gauge-\(UUID().uuidString)"
343343
let value = Double.random(in: -1000 ... 1000)
344344
let gauge = Gauge(label: name)
345345
gauge.record(value)
@@ -353,7 +353,7 @@ class MetricsTests: XCTestCase {
353353
let metrics = TestMetrics()
354354
MetricsSystem.bootstrapInternal(metrics)
355355
// run the test
356-
let name = "gauge-\(NSUUID().uuidString)"
356+
let name = "gauge-\(UUID().uuidString)"
357357
let value = Double.random(in: -1000 ... 1000)
358358
Gauge(label: name).record(value)
359359
let recorder = metrics.recorders[name] as! TestRecorder
@@ -366,7 +366,7 @@ class MetricsTests: XCTestCase {
366366
let factories = [TestMetrics(), TestMetrics(), TestMetrics()]
367367
MetricsSystem.bootstrapInternal(MultiplexMetricsHandler(factories: factories))
368368
// run the test
369-
let name = NSUUID().uuidString
369+
let name = UUID().uuidString
370370
let value = Int.random(in: Int.min ... Int.max)
371371
let muxCounter = Counter(label: name)
372372
muxCounter.increment(by: value)
@@ -388,7 +388,7 @@ class MetricsTests: XCTestCase {
388388
let factories = [TestMetrics(), TestMetrics(), TestMetrics()]
389389
MetricsSystem.bootstrapInternal(MultiplexMetricsHandler(factories: factories))
390390
// run the test
391-
let name = NSUUID().uuidString
391+
let name = UUID().uuidString
392392
let value = Double.random(in: 0 ... 1)
393393
let muxRecorder = Recorder(label: name)
394394
muxRecorder.record(value)
@@ -405,7 +405,7 @@ class MetricsTests: XCTestCase {
405405
let factories = [TestMetrics(), TestMetrics(), TestMetrics()]
406406
MetricsSystem.bootstrapInternal(MultiplexMetricsHandler(factories: factories))
407407
// run the test
408-
let name = NSUUID().uuidString
408+
let name = UUID().uuidString
409409
let seconds = Int.random(in: 1 ... 10)
410410
let muxTimer = Timer(label: name, preferredDisplayUnit: .minutes)
411411
muxTimer.recordSeconds(seconds)
@@ -435,7 +435,7 @@ class MetricsTests: XCTestCase {
435435
let metrics = TestMetrics()
436436
MetricsSystem.bootstrapInternal(metrics)
437437

438-
let name = "gauge-\(NSUUID().uuidString)"
438+
let name = "gauge-\(UUID().uuidString)"
439439
let value = Double.random(in: -1000 ... 1000)
440440

441441
let gauge = Gauge(label: name)
@@ -465,7 +465,7 @@ class MetricsTests: XCTestCase {
465465
let metrics = TestMetrics()
466466
MetricsSystem.bootstrapInternal(metrics)
467467

468-
let name = "counter-\(NSUUID().uuidString)"
468+
let name = "counter-\(UUID().uuidString)"
469469
let value = Int.random(in: 0 ... 1000)
470470

471471
let counter = Counter(label: name)
@@ -495,7 +495,7 @@ class MetricsTests: XCTestCase {
495495
let metrics = TestMetrics()
496496
MetricsSystem.bootstrapInternal(metrics)
497497

498-
let name = "timer-\(NSUUID().uuidString)"
498+
let name = "timer-\(UUID().uuidString)"
499499
let value = Int64.random(in: 0 ... 1000)
500500

501501
let timer = Timer(label: name)

Tests/MetricsTests/MetricsTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MetricsExtensionsTests: XCTestCase {
2222
let metrics = TestMetrics()
2323
MetricsSystem.bootstrapInternal(metrics)
2424
// run the test
25-
let name = "timer-\(NSUUID().uuidString)"
25+
let name = "timer-\(UUID().uuidString)"
2626
let delay = 0.05
2727
Timer.measure(label: name) {
2828
Thread.sleep(forTimeInterval: delay)
@@ -99,7 +99,7 @@ class MetricsExtensionsTests: XCTestCase {
9999
let metrics = TestMetrics()
100100
MetricsSystem.bootstrapInternal(metrics)
101101

102-
let name = "timer-\(NSUUID().uuidString)"
102+
let name = "timer-\(UUID().uuidString)"
103103
let value = Int64.random(in: 0 ... 1000)
104104

105105
let timer = Timer(label: name)
@@ -110,7 +110,7 @@ class MetricsExtensionsTests: XCTestCase {
110110
XCTAssertEqual(testTimer.values.first!.1, value, "expected value to match")
111111
XCTAssertEqual(metrics.timers.count, 1, "timer should have been stored")
112112

113-
let secondsName = "timer-seconds-\(NSUUID().uuidString)"
113+
let secondsName = "timer-seconds-\(UUID().uuidString)"
114114
let secondsValue = Int64.random(in: 0 ... 1000)
115115
let secondsTimer = Timer(label: secondsName, preferredDisplayUnit: .seconds)
116116
secondsTimer.recordSeconds(secondsValue)

Tests/MetricsTests/TestMetrics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internal class TestCounter: CounterHandler, Equatable {
8181
var values = [(Date, Int64)]()
8282

8383
init(label: String, dimensions: [(String, String)]) {
84-
self.id = NSUUID().uuidString
84+
self.id = UUID().uuidString
8585
self.label = label
8686
self.dimensions = dimensions
8787
}
@@ -115,7 +115,7 @@ internal class TestRecorder: RecorderHandler, Equatable {
115115
var values = [(Date, Double)]()
116116

117117
init(label: String, dimensions: [(String, String)], aggregate: Bool) {
118-
self.id = NSUUID().uuidString
118+
self.id = UUID().uuidString
119119
self.label = label
120120
self.dimensions = dimensions
121121
self.aggregate = aggregate
@@ -148,7 +148,7 @@ internal class TestTimer: TimerHandler, Equatable {
148148
var values = [(Date, Int64)]()
149149

150150
init(label: String, dimensions: [(String, String)]) {
151-
self.id = NSUUID().uuidString
151+
self.id = UUID().uuidString
152152
self.label = label
153153
self.displayUnit = nil
154154
self.dimensions = dimensions

Tests/MetricsTests/TestSendable.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SendableTest: XCTestCase {
2424
MetricsSystem.bootstrapInternal(metrics)
2525

2626
do {
27-
let name = "counter-\(NSUUID().uuidString)"
27+
let name = "counter-\(UUID().uuidString)"
2828
let value = Int.random(in: 0 ... 1000)
2929
let counter = Counter(label: name)
3030

@@ -39,7 +39,7 @@ class SendableTest: XCTestCase {
3939
}
4040

4141
do {
42-
let name = "floating-point-counter-\(NSUUID().uuidString)"
42+
let name = "floating-point-counter-\(UUID().uuidString)"
4343
let value = Double.random(in: 0 ... 0.9999)
4444
let counter = FloatingPointCounter(label: name)
4545

@@ -53,7 +53,7 @@ class SendableTest: XCTestCase {
5353
}
5454

5555
do {
56-
let name = "recorder-\(NSUUID().uuidString)"
56+
let name = "recorder-\(UUID().uuidString)"
5757
let value = Double.random(in: -1000 ... 1000)
5858
let recorder = Recorder(label: name)
5959

@@ -68,7 +68,7 @@ class SendableTest: XCTestCase {
6868
}
6969

7070
do {
71-
let name = "gauge-\(NSUUID().uuidString)"
71+
let name = "gauge-\(UUID().uuidString)"
7272
let value = Double.random(in: -1000 ... 1000)
7373
let gauge = Gauge(label: name)
7474

@@ -83,7 +83,7 @@ class SendableTest: XCTestCase {
8383
}
8484

8585
do {
86-
let name = "timer-\(NSUUID().uuidString)"
86+
let name = "timer-\(UUID().uuidString)"
8787
let value = Int64.random(in: 0 ... 1000)
8888
let timer = Timer(label: name)
8989

0 commit comments

Comments
 (0)