@@ -61,7 +61,6 @@ public async Task TestLambdaToUpperV2()
61
61
finally
62
62
{
63
63
await cancellationTokenSource . CancelAsync ( ) ;
64
- await CleanupProcesses ( ) ;
65
64
}
66
65
}
67
66
@@ -97,7 +96,6 @@ public async Task TestLambdaToUpperRest()
97
96
finally
98
97
{
99
98
await cancellationTokenSource . CancelAsync ( ) ;
100
- await CleanupProcesses ( ) ;
101
99
}
102
100
}
103
101
@@ -133,7 +131,6 @@ public async Task TestLambdaToUpperV1()
133
131
finally
134
132
{
135
133
await cancellationTokenSource . CancelAsync ( ) ;
136
- await CleanupProcesses ( ) ;
137
134
}
138
135
}
139
136
@@ -175,7 +172,6 @@ public async Task TestLambdaBinaryResponse()
175
172
finally
176
173
{
177
174
await cancellationTokenSource . CancelAsync ( ) ;
178
- await CleanupProcesses ( ) ;
179
175
}
180
176
}
181
177
@@ -211,7 +207,39 @@ public async Task TestLambdaReturnString()
211
207
finally
212
208
{
213
209
await cancellationTokenSource . CancelAsync ( ) ;
214
- await CleanupProcesses ( ) ;
210
+ }
211
+ }
212
+
213
+ [ Fact ]
214
+ public async Task TestLambdaWithNullEndpoint ( )
215
+ {
216
+ var testProjectDir = Path . GetFullPath ( "../../../../../testapps" ) ;
217
+ var config = new TestConfig
218
+ {
219
+ TestToolPath = Path . GetFullPath ( Path . Combine ( testProjectDir , "../src/Amazon.Lambda.TestTool" ) ) ,
220
+ LambdaPath = Path . GetFullPath ( Path . Combine ( testProjectDir , "LambdaTestFunctionV2" ) ) ,
221
+ FunctionName = "LambdaTestFunctionV2" ,
222
+ RouteName = "testfunction" ,
223
+ HttpMethod = "Post"
224
+ } ;
225
+
226
+ var cancellationTokenSource = new CancellationTokenSource ( ) ;
227
+
228
+ try
229
+ {
230
+ StartTestToolProcessWithNullEndpoint ( ApiGatewayEmulatorMode . HttpV2 , Constants . DefaultApiGatewayEmulatorPort , config , cancellationTokenSource ) ;
231
+ await WaitForGatewayHealthCheck ( Constants . DefaultApiGatewayEmulatorPort ) ;
232
+ await StartLambdaProcess ( config , Constants . DefaultLambdaEmulatorPort ) ;
233
+
234
+ var response = await TestEndpoint ( config , Constants . DefaultApiGatewayEmulatorPort ) ;
235
+ var responseContent = await response . Content . ReadAsStringAsync ( ) ;
236
+
237
+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
238
+ Assert . Equal ( "HELLO WORLD" , responseContent ) ;
239
+ }
240
+ finally
241
+ {
242
+ await cancellationTokenSource . CancelAsync ( ) ;
215
243
}
216
244
}
217
245
@@ -236,6 +264,24 @@ private async Task<HttpResponseMessage> TestEndpoint(TestConfig config, int apiG
236
264
} ;
237
265
}
238
266
267
+ private void StartTestToolProcessWithNullEndpoint ( ApiGatewayEmulatorMode apiGatewayMode , int apiGatewayPort , TestConfig config , CancellationTokenSource cancellationTokenSource )
268
+ {
269
+ Environment . SetEnvironmentVariable ( "ASPNETCORE_ENVIRONMENT" , "Development" ) ;
270
+ Environment . SetEnvironmentVariable ( "APIGATEWAY_EMULATOR_ROUTE_CONFIG" , $@ "{{
271
+ ""LambdaResourceName"": ""{ config . RouteName } "",
272
+ ""HttpMethod"": ""{ config . HttpMethod } "",
273
+ ""Path"": ""/{ config . RouteName } ""
274
+ }}" ) ;
275
+
276
+ cancellationTokenSource . CancelAfter ( 5000 ) ;
277
+ var settings = new RunCommandSettings { NoLaunchWindow = true , ApiGatewayEmulatorMode = apiGatewayMode , ApiGatewayEmulatorPort = apiGatewayPort } ;
278
+
279
+ var command = new RunCommand ( _mockInteractiveService . Object , _mockEnvironmentManager . Object ) ;
280
+ var context = new CommandContext ( new List < string > ( ) , _mockRemainingArgs . Object , "run" , null ) ;
281
+
282
+ _ = command . ExecuteAsync ( context , settings , cancellationTokenSource ) ;
283
+ }
284
+
239
285
private void StartTestToolProcess ( ApiGatewayEmulatorMode apiGatewayMode , TestConfig config , int lambdaPort , int apiGatewayPort , CancellationTokenSource cancellationTokenSource )
240
286
{
241
287
Environment . SetEnvironmentVariable ( "ASPNETCORE_ENVIRONMENT" , "Development" ) ;
0 commit comments