Skip to content

Commit 918492a

Browse files
sebstofabianfett
andauthored
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
Co-authored-by: Fabian Fett <[email protected]>
1 parent c1e68fc commit 918492a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

Diff for: Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift

+18-14
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,27 @@ struct LambdaRuntimeTests {
4040
logger: Logger(label: "Runtime1")
4141
)
4242

43-
// start the first runtime
44-
let task1 = Task {
45-
try await runtime1.run()
46-
}
47-
48-
// wait a small amount to ensure runtime1 task is started
49-
try await Task.sleep(for: .seconds(1))
43+
try await withThrowingTaskGroup(of: Void.self) { taskGroup in
44+
// start the first runtime
45+
taskGroup.addTask {
46+
await #expect(throws: Never.self) {
47+
try await runtime1.run()
48+
}
49+
}
50+
51+
// wait a small amount to ensure runtime1 task is started
52+
try await Task.sleep(for: .seconds(1))
5053

51-
// Running the second runtime should trigger LambdaRuntimeError
52-
await #expect(throws: LambdaRuntimeError.self) {
53-
try await runtime2.run()
54+
// Running the second runtime should trigger LambdaRuntimeError
55+
await #expect(throws: LambdaRuntimeError.self) {
56+
try await runtime2.run()
57+
}
58+
59+
// cancel runtime 1 / task 1
60+
print("--- cancelling ---")
61+
taskGroup.cancelAll()
5462
}
5563

56-
// cancel runtime 1 / task 1
57-
print("--- cancelling ---")
58-
task1.cancel()
59-
6064
// Running the second runtime should work now
6165
await #expect(throws: Never.self) {
6266

0 commit comments

Comments
 (0)