|
25 | 25 | // SOFTWARE.
|
26 | 26 |
|
27 | 27 | import Queuer
|
28 |
| -import XCTest |
| 28 | +import Testing |
29 | 29 |
|
30 |
| -final class AsyncConcurrentOperationTests: XCTestCase { |
31 |
| - func testAsyncChainedRetry() async { |
32 |
| - let queue = Queuer(name: "ConcurrentOperationTestChainedRetry") |
33 |
| - let testExpectation = expectation(description: "Chained Retry") |
34 |
| - let order = Order() |
| 30 | +@Suite struct AsyncConcurrentOperationTests { |
| 31 | + @Test func asyncChainedRetry() async throws { |
| 32 | + try await confirmation("Chainer Retry") { confirmation in |
| 33 | + let queue = Queuer(name: "ConcurrentOperationTestChainedRetry") |
| 34 | + let order = Order() |
35 | 35 |
|
36 |
| - let concurrentOperation1 = AsyncConcurrentOperation { operation in |
37 |
| - try? await Task.sleep(for: .seconds(1)) |
38 |
| - await order.append(0) |
39 |
| - operation.success = false |
40 |
| - } |
41 |
| - let concurrentOperation2 = AsyncConcurrentOperation { operation in |
42 |
| - await order.append(1) |
43 |
| - operation.success = false |
44 |
| - } |
45 |
| - queue.addChainedAsyncOperations([concurrentOperation1, concurrentOperation2]) { |
46 |
| - await order.append(2) |
47 |
| - testExpectation.fulfill() |
48 |
| - } |
| 36 | + let concurrentOperation1 = AsyncConcurrentOperation { operation in |
| 37 | + try await Task.sleep(for: .seconds(1)) |
| 38 | + await order.append(0) |
| 39 | + operation.success = false |
| 40 | + } |
| 41 | + let concurrentOperation2 = AsyncConcurrentOperation { operation in |
| 42 | + await order.append(1) |
| 43 | + operation.success = false |
| 44 | + } |
| 45 | + queue.addChainedAsyncOperations([concurrentOperation1, concurrentOperation2]) { |
| 46 | + await order.append(2) |
| 47 | + confirmation() |
| 48 | + } |
49 | 49 |
|
50 |
| - await fulfillment(of: [testExpectation], timeout: 10) |
51 |
| - let finalOrder = await order.order |
52 |
| - XCTAssertEqual(finalOrder, [0, 0, 0, 1, 1, 1, 2]) |
| 50 | + try await Task.sleep(for: .seconds(5)) |
| 51 | + |
| 52 | + let finalOrder = await order.order |
| 53 | + #expect(finalOrder == [0, 0, 0, 1, 1, 1, 2]) |
| 54 | + } |
53 | 55 | }
|
54 | 56 | }
|
0 commit comments