Skip to content

Commit 38d9e8a

Browse files
feat: use Testing instead of XCTest
1 parent ce6d56a commit 38d9e8a

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

Tests/QueuerTests/AsyncConcurrentOperationTests.swift

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,32 @@
2525
// SOFTWARE.
2626

2727
import Queuer
28-
import XCTest
28+
import Testing
2929

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()
3535

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+
}
4949

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+
}
5355
}
5456
}

0 commit comments

Comments
 (0)