Skip to content

Commit 11c56e2

Browse files
entities: Remove AssertionFailure.taskExplicitlyCanceled case
We need to be able to cancel the task ourselves and test this logic. The current assertion does not allow us to do this.
1 parent 84bf70d commit 11c56e2

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

Sources/Entities/AsyncStub.swift

+2-10
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ extension AsyncStub: AsyncInvokable {
2727
.handleFatalError(.testDoubleTypeMismatch(expected: "Async", received: "Throwing"), location: nil)
2828
}
2929

30-
do {
31-
try await Task.sleep(nanoseconds: delayInNanoseconds)
32-
} catch {
33-
FailureReporter.handler.handleFatalError(.taskExplicitlyCanceled, location: nil)
34-
}
30+
try? await Task.sleep(nanoseconds: delayInNanoseconds)
3531
return result
3632
}
3733
}
@@ -41,11 +37,7 @@ extension AsyncStub: ThrowingAsyncInvokable {
4137

4238
@Sendable
4339
func throwingAsyncInvoke(arguments: [Any]) async throws -> Value {
44-
do {
45-
try await Task.sleep(nanoseconds: delayInNanoseconds)
46-
} catch {
47-
FailureReporter.handler.handleFatalError(.taskExplicitlyCanceled, location: nil)
48-
}
40+
try await Task.sleep(nanoseconds: delayInNanoseconds)
4941

5042
switch stubbedValue {
5143
case .success(let value):

Sources/FailureReporter/AssertionFailure.swift

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public enum AssertionFailure: Error {
99
case expectedToBeCalledOnce(calledCount: Int)
1010
case expectedToBeCalledTimes(expectedCount: Int, calledCount: Int)
1111
case testDoubleTypeMismatch(expected: String, received: String)
12-
case taskExplicitlyCanceled
1312
}
1413

1514
extension AssertionFailure {
@@ -34,8 +33,6 @@ extension AssertionFailure {
3433
return "Expected to be called \(expectedCount) time(s) but called \(calledCount) time(s)"
3534
case .testDoubleTypeMismatch(let expected, let received):
3635
return "Expected closure to be type of \(expected), received \(received)"
37-
case .taskExplicitlyCanceled:
38-
return "Task explicitly canceled"
3936
}
4037
}
4138
}

0 commit comments

Comments
 (0)