Skip to content

Commit abdda82

Browse files
committed
move service lifecycle test in a separate file
1 parent 3b190c3 commit abdda82

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#if ServiceLifecycleSupport
2+
@testable import AWSLambdaRuntime
3+
import ServiceLifecycle
4+
import Testing
5+
import Logging
6+
7+
@Suite
8+
struct LambdaRuntimeServiceLifecycleTests {
9+
@Test
10+
func testLambdaRuntimeGracefulShutdown() async throws {
11+
let runtime = LambdaRuntime {
12+
(event: String, context: LambdaContext) in
13+
"Hello \(event)"
14+
}
15+
16+
let serviceGroup = ServiceGroup(
17+
services: [runtime],
18+
gracefulShutdownSignals: [.sigterm, .sigint],
19+
logger: Logger(label: "TestLambdaRuntimeGracefulShutdown")
20+
)
21+
try await withThrowingTaskGroup(of: Void.self) { group in
22+
group.addTask {
23+
try await serviceGroup.run()
24+
}
25+
// wait a small amount to ensure we are waiting for continuation
26+
try await Task.sleep(for: .milliseconds(100))
27+
28+
await serviceGroup.triggerGracefulShutdown()
29+
}
30+
}
31+
}
32+
#endif

Tests/AWSLambdaRuntimeTests/LambdaRuntimeClientTests.swift

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import Logging
1616
import NIOCore
1717
import NIOPosix
18-
import ServiceLifecycle
1918
import Testing
2019

2120
import struct Foundation.UUID
@@ -140,28 +139,4 @@ struct LambdaRuntimeClientTests {
140139
}
141140
}
142141
}
143-
#if ServiceLifecycleSupport
144-
@Test
145-
func testLambdaRuntimeGracefulShutdown() async throws {
146-
let runtime = LambdaRuntime {
147-
(event: String, context: LambdaContext) in
148-
"Hello \(event)"
149-
}
150-
151-
let serviceGroup = ServiceGroup(
152-
services: [runtime],
153-
gracefulShutdownSignals: [.sigterm, .sigint],
154-
logger: Logger(label: "TestLambdaRuntimeGracefulShutdown")
155-
)
156-
try await withThrowingTaskGroup(of: Void.self) { group in
157-
group.addTask {
158-
try await serviceGroup.run()
159-
}
160-
// wait a small amount to ensure we are waiting for continuation
161-
try await Task.sleep(for: .milliseconds(100))
162-
163-
await serviceGroup.triggerGracefulShutdown()
164-
}
165-
}
166-
#endif
167142
}

0 commit comments

Comments
 (0)