File tree 1 file changed +18
-14
lines changed
Tests/AWSLambdaRuntimeTests
1 file changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -40,23 +40,27 @@ struct LambdaRuntimeTests {
40
40
logger: Logger ( label: " Runtime1 " )
41
41
)
42
42
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 ) )
50
53
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 ( )
54
62
}
55
63
56
- // cancel runtime 1 / task 1
57
- print ( " --- cancelling --- " )
58
- task1. cancel ( )
59
-
60
64
// Running the second runtime should work now
61
65
await #expect( throws: Never . self) {
62
66
You can’t perform that action at this time.
0 commit comments