Skip to content

Commit

Permalink
Simple cancellation test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jun 18, 2023
1 parent fde8fad commit bb2ea43
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Tests/QueueTests/AsyncQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,27 @@ final class QueueTests: XCTestCase {

await fulfillment(of: [expA, expB], enforceOrder: true)
}

func testCancelOperation() async throws {
let queue = AsyncQueue(attributes: [])

let expA = expectation(description: "Task A")
expA.isInverted = true

let expB = expectation(description: "Task B")

let task = queue.addOperation {
try await Task.sleep(milliseconds: 100)

expA.fulfill()
}

queue.addOperation {
expB.fulfill()
}

task.cancel()

await fulfillment(of: [expA, expB], timeout: 0.5, enforceOrder: true)
}
}

0 comments on commit bb2ea43

Please sign in to comment.