Skip to content

Commit 64bc936

Browse files
committed
Async fire-and-forget (#1083)
* Make fireAndForget async. * wip * tests
1 parent 4de8597 commit 64bc936

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Tests/ComposableArchitectureTests/EffectTests.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ final class EffectTests: XCTestCase {
233233
disposable.dispose()
234234
}
235235

236-
func testCancellingTask() {
236+
func testCancellingTask_Failable() {
237237
@Sendable func work() async throws -> Int {
238238
try await Task.sleep(nanoseconds: NSEC_PER_MSEC)
239239
XCTFail()
@@ -251,5 +251,27 @@ final class EffectTests: XCTestCase {
251251
disposable.dispose()
252252
_ = XCTWaiter.wait(for: [.init()], timeout: 1.1)
253253
}
254+
255+
func testCancellingTask_Infalable() {
256+
@Sendable func work() async -> Int {
257+
do {
258+
try await Task.sleep(nanoseconds: NSEC_PER_MSEC)
259+
XCTFail()
260+
} catch {
261+
}
262+
return 42
263+
}
264+
265+
Effect<Int, Never >.task { await work() }
266+
.sink(
267+
receiveCompletion: { _ in XCTFail() },
268+
receiveValue: { _ in XCTFail() }
269+
)
270+
.store(in: &self.cancellables)
271+
272+
self.cancellables = []
273+
274+
_ = XCTWaiter.wait(for: [.init()], timeout: 1.1)
275+
}
254276
#endif
255277
}

0 commit comments

Comments
 (0)