File tree Expand file tree Collapse file tree 1 file changed +18
-14
lines changed
Tests/AWSLambdaRuntimeTests Expand file tree Collapse file tree 1 file changed +18
-14
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments