@@ -37,32 +37,32 @@ struct BreezeLambdaWebHookServiceTests {
37
37
#expect( context. httpClient === httpClient)
38
38
}
39
39
40
- // @Test("Service creates HTTP client with correct timeout configuration")
41
- // func serviceCreatesHTTPClientWithCorrectConfig() async throws {
42
- // try await testGracefulShutdown { gracefulShutdownTestTrigger in
43
- // try await withThrowingTaskGroup(of: Void.self) { group in
44
- // let logger = Logger(label: "test")
45
- // let config = BreezeHTTPClientConfig(timeout: .seconds(30), logger: logger)
46
- // let sut = BreezeLambdaWebHookService<MockHandler>(config: config)
47
- //
48
- // await withTaskCancellationOrGracefulShutdownHandler {
49
- // group.addTask {
50
- // try await sut.run()
51
- // }
52
- // } onCancelOrGracefulShutdown: {
53
- // gracefulShutdownTestTrigger.triggerGracefulShutdown()
54
- // logger.info("On Graceful Shutdown")
55
- // }
56
- //
57
- // try await Task.sleep(nanoseconds: 1_000_000_000)
58
- // group.cancelAll()
59
- //
60
- // let handlerContext = try #require(await sut.handlerContext)
61
- // #expect(handlerContext.httpClient.configuration.timeout.read == .seconds(30))
62
- // #expect(handlerContext.httpClient.configuration.timeout.connect == .seconds(30))
63
- // }
64
- // }
65
- // }
40
+ @Test ( " Service creates HTTP client with correct timeout configuration " )
41
+ func serviceCreatesHTTPClientWithCorrectConfig( ) async throws {
42
+ try await testGracefulShutdown { gracefulShutdownTestTrigger in
43
+ try await withThrowingTaskGroup ( of: Void . self) { group in
44
+ let logger = Logger ( label: " test " )
45
+ let config = BreezeHTTPClientConfig ( timeout: . seconds( 30 ) , logger: logger)
46
+ let sut = BreezeLambdaWebHookService < MockHandler > ( config: config)
47
+
48
+ await withTaskCancellationOrGracefulShutdownHandler {
49
+ group. addTask {
50
+ try await sut. run ( )
51
+ }
52
+ } onCancelOrGracefulShutdown: {
53
+ gracefulShutdownTestTrigger. triggerGracefulShutdown ( )
54
+ logger. info ( " On Graceful Shutdown " )
55
+ }
56
+
57
+ try await Task . sleep ( nanoseconds: 1_000_000_000 )
58
+ group. cancelAll ( )
59
+
60
+ let handlerContext = try #require( await sut. handlerContext)
61
+ #expect( handlerContext. httpClient. configuration. timeout. read == . seconds( 30 ) )
62
+ #expect( handlerContext. httpClient. configuration. timeout. connect == . seconds( 30 ) )
63
+ }
64
+ }
65
+ }
66
66
67
67
@Test ( " Handler throws when handlerContext is nil " )
68
68
func handlerThrowsWhenContextIsNil( ) async throws {
@@ -79,43 +79,42 @@ struct BreezeLambdaWebHookServiceTests {
79
79
}
80
80
}
81
81
82
- // @Test("Handler delegates to specific handler implementation")
83
- // func handlerDelegatesToImplementation() async throws {
84
- // try await testGracefulShutdown { gracefulShutdownTestTrigger in
85
- // try await withThrowingTaskGroup(of: Void.self) { group in
86
- //
87
- // let logger = Logger(label: "test")
88
- // let config = BreezeHTTPClientConfig(timeout: .seconds(30), logger: logger)
89
- // let sut = BreezeLambdaWebHookService<MockHandler>(config: config)
90
- //
91
- // group.addTask {
92
- // try await withGracefulShutdownHandler {
93
- // try await sut.run()
94
- // } onGracefulShutdown: {
95
- // logger.info("On Graceful Shutdown")
96
- // }
97
- // }
98
- // group.addTask {
99
- // try await Task.sleep(nanoseconds: 1_000_000_000)
100
- // gracefulShutdownTestTrigger.triggerGracefulShutdown()
101
- // }
102
- //
103
- // let createRequest = try Fixtures.fixture(name: Fixtures.getWebHook, type: "json")
104
- // let event = try decoder.decode(APIGatewayV2Request.self, from: createRequest)
105
- // let context = LambdaContext(requestID: "req1", traceID: "trace1", invokedFunctionARN: "", deadline: .now(), logger: logger)
106
- //
107
- // let response = try await sut.handler(event: event, context: context)
108
- // let handlerContext = try #require(await sut.handlerContext)
109
- // #expect(response.statusCode == 200)
110
- // #expect(response.body == "Mock response")
111
- // #expect(handlerContext.httpClient.configuration.timeout.read == .seconds(30))
112
- // #expect(handlerContext.httpClient.configuration.timeout.connect == .seconds(30))
113
- //
114
- //
115
- // group.cancelAll()
116
- // }
117
- // }
118
- // }
82
+ @Test ( " Handler delegates to specific handler implementation " )
83
+ func handlerDelegatesToImplementation( ) async throws {
84
+ try await testGracefulShutdown { gracefulShutdownTestTrigger in
85
+ try await withThrowingTaskGroup ( of: Void . self) { group in
86
+
87
+ let logger = Logger ( label: " test " )
88
+ let config = BreezeHTTPClientConfig ( timeout: . seconds( 30 ) , logger: logger)
89
+ let sut = BreezeLambdaWebHookService < MockHandler > ( config: config)
90
+
91
+ group. addTask {
92
+ try await withGracefulShutdownHandler {
93
+ try await sut. run ( )
94
+ } onGracefulShutdown: {
95
+ logger. info ( " On Graceful Shutdown " )
96
+ }
97
+ }
98
+ group. addTask {
99
+ try await Task . sleep ( nanoseconds: 1_000_000_000 )
100
+ gracefulShutdownTestTrigger. triggerGracefulShutdown ( )
101
+ }
102
+
103
+ let createRequest = try Fixtures . fixture ( name: Fixtures . getWebHook, type: " json " )
104
+ let event = try decoder. decode ( APIGatewayV2Request . self, from: createRequest)
105
+ let context = LambdaContext ( requestID: " req1 " , traceID: " trace1 " , invokedFunctionARN: " " , deadline: . now( ) , logger: logger)
106
+
107
+ let response = try await sut. handler ( event: event, context: context)
108
+ let handlerContext = try #require( await sut. handlerContext)
109
+ #expect( response. statusCode == 200 )
110
+ #expect( response. body == " Mock response " )
111
+ #expect( handlerContext. httpClient. configuration. timeout. read == . seconds( 30 ) )
112
+ #expect( handlerContext. httpClient. configuration. timeout. connect == . seconds( 30 ) )
113
+
114
+ group. cancelAll ( )
115
+ }
116
+ }
117
+ }
119
118
}
120
119
121
120
struct MockHandler : BreezeLambdaWebHookHandler {
0 commit comments