Example #1
0
        public void IsRunningInLambdaFalseNoFileAndEnvironmentVariable()
        {
            var originalValue = Environment.GetEnvironmentVariable(FunctionNameEnvVar);

            Environment.SetEnvironmentVariable(FunctionNameEnvVar, "my-test-function");
            string path = Directory.GetCurrentDirectory() + "/invalid";
            var    res  = Serverless.IsRunningInLambda(path);

            Environment.SetEnvironmentVariable(FunctionNameEnvVar, originalValue);
            res.Should().Be(false);
        }
Example #2
0
        public void IsRunningInLambdaTrue()
        {
            var originalValue = Environment.GetEnvironmentVariable(FunctionNameEnvVar);

            Environment.SetEnvironmentVariable(FunctionNameEnvVar, "my-test-function");
            string currentDirectory = Directory.GetCurrentDirectory();
            string existingFile     = Directory.GetFiles(currentDirectory)[0];
            var    res = Serverless.IsRunningInLambda(existingFile);

            Environment.SetEnvironmentVariable(FunctionNameEnvVar, originalValue);
            res.Should().Be(true);
        }
Example #3
0
        public void IsRunningInLambdaFalseFileAndNoEnvironmentVariable()
        {
            var originalValue = Environment.GetEnvironmentVariable(FunctionNameEnvVar);

            Environment.SetEnvironmentVariable(FunctionNameEnvVar, string.Empty);
            string currentDirectory = Directory.GetCurrentDirectory();
            string existingFile     = Directory.GetFiles(currentDirectory)[0];
            var    res = Serverless.IsRunningInLambda(existingFile);

            Environment.SetEnvironmentVariable(FunctionNameEnvVar, originalValue);
            res.Should().Be(false);
        }