public static string GetLambdaInvokeEndpoint(ITestOutputHelper outputHelper, LambdaTestHost lambdaTestHost) { var lambdaForwardUrlBuilder = new UriBuilder(lambdaTestHost.ServiceUrl); if (!IsRunningInContainer) { lambdaForwardUrlBuilder.Host = "host.docker.internal"; } var lambdaForwardUrl = lambdaForwardUrlBuilder.ToString(); // Remove trailing slash as localstack does string concatenation resulting in "//". lambdaForwardUrl = lambdaForwardUrl.Remove(lambdaForwardUrl.Length - 1); outputHelper.WriteLine($"Using LAMBDA_FALLBACK_URL={lambdaForwardUrl}"); return(lambdaForwardUrl); }
public async Task InitializeAsync() { _settings = new LambdaTestHostSettings(() => new TestLambdaContext { Logger = new XunitLambdaLogger(_outputHelper), }); _settings.AddFunction( new LambdaFunctionInfo( nameof(BrokenFunction), typeof(BrokenFunction), nameof(BrokenFunction.Handle))); _settings.AddFunction( new LambdaFunctionInfo( nameof(APIGatewayFunction), typeof(APIGatewayFunction), nameof(APIGatewayFunction.Handle))); _settings.AddFunction( new LambdaFunctionInfo( nameof(ReverseStringFunction), typeof(ReverseStringFunction), nameof(ReverseStringFunction.Reverse))); _settings.AddFunction( new LambdaFunctionInfo( nameof(SleepFunction), typeof(SleepFunction), nameof(SleepFunction.Handle), 1)); _testHost = await LambdaTestHost.Start(_settings); var awsCredentials = new BasicAWSCredentials("not", "used"); var lambdaConfig = new AmazonLambdaConfig { ServiceURL = _testHost.ServiceUrl.ToString().Replace("[::]", "localhost"), MaxErrorRetry = 0 }; _lambdaClient = new AmazonLambdaClient(awsCredentials, lambdaConfig); }