Skip to content

Commit 268dfb6

Browse files
committed
added: sleep constant int tests
1 parent 36242b7 commit 268dfb6

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Tests/DataLoaderTests/DataLoaderTests.swift

+19-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import XCTest
22

33
@testable import DataLoader
44

5+
let sleepConstant = UInt64(2_000_000)
6+
57
actor Concurrent<T> {
68
var wrappedValue: T
79

@@ -69,7 +71,7 @@ final class DataLoaderTests: XCTestCase {
6971
async let value1 = identityLoader.load(key: 1)
7072
async let value2 = identityLoader.load(key: 2)
7173

72-
try await Task.sleep(nanoseconds: 2_000_000)
74+
try await Task.sleep(nanoseconds: sleepConstant)
7375

7476
var didFailWithError: Error?
7577

@@ -112,7 +114,7 @@ final class DataLoaderTests: XCTestCase {
112114
async let value2 = identityLoader.load(key: 2)
113115
async let value3 = identityLoader.load(key: 3)
114116

115-
try await Task.sleep(nanoseconds: 2_000_000)
117+
try await Task.sleep(nanoseconds: sleepConstant)
116118

117119
var didFailWithError: Error?
118120

@@ -151,7 +153,7 @@ final class DataLoaderTests: XCTestCase {
151153
async let value1 = identityLoader.load(key: 1)
152154
async let value2 = identityLoader.load(key: 1)
153155

154-
try await Task.sleep(nanoseconds: 2_000_000)
156+
try await Task.sleep(nanoseconds: sleepConstant)
155157

156158
var didFailWithError: Error?
157159

@@ -189,7 +191,7 @@ final class DataLoaderTests: XCTestCase {
189191
async let value1 = identityLoader.load(key: "A")
190192
async let value2 = identityLoader.load(key: "B")
191193

192-
try await Task.sleep(nanoseconds: 2_000_000)
194+
try await Task.sleep(nanoseconds: sleepConstant)
193195

194196
var didFailWithError: Error?
195197

@@ -214,7 +216,7 @@ final class DataLoaderTests: XCTestCase {
214216
async let value3 = identityLoader.load(key: "A")
215217
async let value4 = identityLoader.load(key: "C")
216218

217-
try await Task.sleep(nanoseconds: 2_000_000)
219+
try await Task.sleep(nanoseconds: sleepConstant)
218220

219221
var didFailWithError2: Error?
220222

@@ -240,7 +242,7 @@ final class DataLoaderTests: XCTestCase {
240242
async let value6 = identityLoader.load(key: "B")
241243
async let value7 = identityLoader.load(key: "C")
242244

243-
try await Task.sleep(nanoseconds: 2_000_000)
245+
try await Task.sleep(nanoseconds: sleepConstant)
244246

245247
var didFailWithError3: Error?
246248

@@ -280,7 +282,7 @@ final class DataLoaderTests: XCTestCase {
280282
async let value1 = identityLoader.load(key: "A")
281283
async let value2 = identityLoader.load(key: "B")
282284

283-
try await Task.sleep(nanoseconds: 2_000_000)
285+
try await Task.sleep(nanoseconds: sleepConstant)
284286

285287
var didFailWithError: Error?
286288

@@ -307,7 +309,7 @@ final class DataLoaderTests: XCTestCase {
307309
async let value3 = identityLoader.load(key: "A")
308310
async let value4 = identityLoader.load(key: "B")
309311

310-
try await Task.sleep(nanoseconds: 2_000_000)
312+
try await Task.sleep(nanoseconds: sleepConstant)
311313

312314
var didFailWithError2: Error?
313315

@@ -345,7 +347,7 @@ final class DataLoaderTests: XCTestCase {
345347
async let value1 = identityLoader.load(key: "A")
346348
async let value2 = identityLoader.load(key: "B")
347349

348-
try await Task.sleep(nanoseconds: 2_000_000)
350+
try await Task.sleep(nanoseconds: sleepConstant)
349351

350352
var didFailWithError: Error?
351353

@@ -372,7 +374,7 @@ final class DataLoaderTests: XCTestCase {
372374
async let value3 = identityLoader.load(key: "A")
373375
async let value4 = identityLoader.load(key: "B")
374376

375-
try await Task.sleep(nanoseconds: 2_000_000)
377+
try await Task.sleep(nanoseconds: sleepConstant)
376378

377379
var didFailWithError2: Error?
378380

@@ -412,7 +414,7 @@ final class DataLoaderTests: XCTestCase {
412414
async let value1 = identityLoader.load(key: "A")
413415
async let value2 = identityLoader.load(key: "B")
414416

415-
try await Task.sleep(nanoseconds: 2_000_000)
417+
try await Task.sleep(nanoseconds: sleepConstant)
416418

417419
var didFailWithError: Error?
418420

@@ -452,7 +454,7 @@ final class DataLoaderTests: XCTestCase {
452454
async let value1 = identityLoader.load(key: "A")
453455
async let value2 = identityLoader.load(key: "B")
454456

455-
try await Task.sleep(nanoseconds: 2_000_000)
457+
try await Task.sleep(nanoseconds: sleepConstant)
456458

457459
var didFailWithError: Error?
458460

@@ -476,7 +478,7 @@ final class DataLoaderTests: XCTestCase {
476478
async let value3 = identityLoader.load(key: "A")
477479
async let value4 = identityLoader.load(key: "B")
478480

479-
try await Task.sleep(nanoseconds: 2_000_000)
481+
try await Task.sleep(nanoseconds: sleepConstant)
480482

481483
var didFailWithError2: Error?
482484

@@ -516,7 +518,7 @@ final class DataLoaderTests: XCTestCase {
516518
async let value1 = identityLoader.load(key: "A")
517519
async let value2 = identityLoader.load(key: "B")
518520

519-
try await Task.sleep(nanoseconds: 2_000_000)
521+
try await Task.sleep(nanoseconds: sleepConstant)
520522

521523
var didFailWithError: Error?
522524

@@ -540,7 +542,7 @@ final class DataLoaderTests: XCTestCase {
540542
async let value3 = identityLoader.load(key: "A")
541543
async let value4 = identityLoader.load(key: "B")
542544

543-
try await Task.sleep(nanoseconds: 2_000_000)
545+
try await Task.sleep(nanoseconds: sleepConstant)
544546

545547
var didFailWithError2: Error?
546548

@@ -565,7 +567,7 @@ final class DataLoaderTests: XCTestCase {
565567

566568
func testAutoExecute() async throws {
567569
let identityLoader = DataLoader<String, String>(
568-
options: DataLoaderOptions(executionPeriod: 2_000_000)
570+
options: DataLoaderOptions(executionPeriod: sleepConstant)
569571
) { keys in
570572

571573
keys.map { DataLoaderValue.success($0) }
@@ -593,7 +595,7 @@ final class DataLoaderTests: XCTestCase {
593595

594596
async let value = throwLoader.load(key: 1)
595597

596-
try await Task.sleep(nanoseconds: 2_000_000)
598+
try await Task.sleep(nanoseconds: sleepConstant)
597599

598600
var didFailWithError: DataLoaderError?
599601

0 commit comments

Comments
 (0)