@@ -38,7 +38,7 @@ public async Task TestLambdaToUpperV2()
38
38
39
39
try
40
40
{
41
- await StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config ) ;
41
+ StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config ) ;
42
42
await WaitForGatewayHealthCheck ( ) ;
43
43
await StartLambdaProcess ( config ) ;
44
44
@@ -69,7 +69,7 @@ public async Task TestLambdaToUpperRest()
69
69
70
70
try
71
71
{
72
- await StartTestToolProcess ( ApiGatewayEmulatorMode . Rest , config ) ;
72
+ StartTestToolProcess ( ApiGatewayEmulatorMode . Rest , config ) ;
73
73
await WaitForGatewayHealthCheck ( ) ;
74
74
await StartLambdaProcess ( config ) ;
75
75
@@ -100,7 +100,7 @@ public async Task TestLambdaToUpperV1()
100
100
101
101
try
102
102
{
103
- await StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV1 , config ) ;
103
+ StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV1 , config ) ;
104
104
await WaitForGatewayHealthCheck ( ) ;
105
105
await StartLambdaProcess ( config ) ;
106
106
@@ -131,7 +131,7 @@ public async Task TestLambdaBinaryResponse()
131
131
132
132
try
133
133
{
134
- await StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config ) ;
134
+ StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config ) ;
135
135
await WaitForGatewayHealthCheck ( ) ;
136
136
await StartLambdaProcess ( config ) ;
137
137
@@ -168,7 +168,38 @@ public async Task TestLambdaReturnString()
168
168
169
169
try
170
170
{
171
- await StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config ) ;
171
+ StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config ) ;
172
+ await WaitForGatewayHealthCheck ( ) ;
173
+ await StartLambdaProcess ( config ) ;
174
+
175
+ var response = await TestEndpoint ( config ) ;
176
+ var responseContent = await response . Content . ReadAsStringAsync ( ) ;
177
+
178
+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
179
+ Assert . Equal ( "HELLO WORLD" , responseContent ) ;
180
+ }
181
+ finally
182
+ {
183
+ await CleanupProcesses ( ) ;
184
+ }
185
+ }
186
+
187
+ [ Fact ]
188
+ public async Task TestLambdaWithNullEndpoint ( )
189
+ {
190
+ var testProjectDir = Path . GetFullPath ( "../../../../" ) ;
191
+ var config = new TestConfig
192
+ {
193
+ TestToolPath = Path . GetFullPath ( Path . Combine ( testProjectDir , "../src/Amazon.Lambda.TestTool" ) ) ,
194
+ LambdaPath = Path . GetFullPath ( Path . Combine ( testProjectDir , "LambdaTestFunctionV2/src/LambdaTestFunctionV2" ) ) ,
195
+ FunctionName = "LambdaTestFunctionV2" ,
196
+ RouteName = "testfunction" ,
197
+ HttpMethod = "Post"
198
+ } ;
199
+
200
+ try
201
+ {
202
+ StartTestToolProcess ( ApiGatewayEmulatorMode . HttpV2 , config , useNullEndpoint : true ) ;
172
203
await WaitForGatewayHealthCheck ( ) ;
173
204
await StartLambdaProcess ( config ) ;
174
205
@@ -205,7 +236,7 @@ private async Task<HttpResponseMessage> TestEndpoint(TestConfig config, HttpCont
205
236
} ;
206
237
}
207
238
208
- private async Task StartTestToolProcess ( ApiGatewayEmulatorMode apiGatewayMode , TestConfig config )
239
+ private void StartTestToolProcess ( ApiGatewayEmulatorMode apiGatewayMode , TestConfig config , bool useNullEndpoint = false )
209
240
{
210
241
var startInfo = new ProcessStartInfo
211
242
{
@@ -217,14 +248,21 @@ private async Task StartTestToolProcess(ApiGatewayEmulatorMode apiGatewayMode, T
217
248
CreateNoWindow = true
218
249
} ;
219
250
220
- startInfo . EnvironmentVariables [ "ASPNETCORE_ENVIRONMENT" ] = "Development" ;
221
- startInfo . EnvironmentVariables [ "APIGATEWAY_EMULATOR_ROUTE_CONFIG" ] = $@ "{{
251
+ var routeConfig = useNullEndpoint
252
+ ? $@ "{{
253
+ ""LambdaResourceName"": ""{ config . RouteName } "",
254
+ ""HttpMethod"": ""{ config . HttpMethod } "",
255
+ ""Path"": ""/{ config . RouteName } ""
256
+ }}"
257
+ : $@ "{{
222
258
""LambdaResourceName"": ""{ config . RouteName } "",
223
259
""Endpoint"": ""http://localhost:{ LambdaPort } "",
224
260
""HttpMethod"": ""{ config . HttpMethod } "",
225
261
""Path"": ""/{ config . RouteName } ""
226
262
}}" ;
227
263
264
+ startInfo . EnvironmentVariables [ "APIGATEWAY_EMULATOR_ROUTE_CONFIG" ] = routeConfig ;
265
+
228
266
_mainProcess = Process . Start ( startInfo ) ?? throw new Exception ( "Failed to start test tool process" ) ;
229
267
ConfigureProcessLogging ( _mainProcess , "TestTool" ) ;
230
268
}
0 commit comments