Exemple #1
0
        public void ShouldResolveRelativeDependencies(string format)
        {
            var deleteMap = new Dictionary <string, string> {
                { "json", "yaml" }, { "yaml", "json" }
            };

            // dependencyFiles temp dir is initialized each test by ctor,
            // so delete the dependency file NOT being tested
            File.Delete(Path.Combine(this.dependencyFiles, $"lambda-dependencies.{deleteMap[format]}"));

            var lambdaFunctionResource =
                this.LambdaFunctionResource("index.handler", "nodejs10.x", this.dependencyFiles.FullPath);

            var mockOSInfo = new Mock <IOSInfo>();

            mockOSInfo.Setup(i => i.OSPlatform).Returns(OSPlatform.Windows);

            var artifact = new LambdaArtifact(
                new TestPathResolver(),
                lambdaFunctionResource,
                new TestLogger(this.output),
                mockOSInfo.Object,
                this.dependencyFiles);

            var dependencyFile         = Path.Combine(this.dependencyFiles, $"lambda-dependencies.{format}");
            var expectedDependencyPath = Path.GetFullPath(Path.Combine(new FileInfo(dependencyFile).DirectoryName, "../modules"));

            // Last entry in the lambda-dependencies files has a relative link
            var relativeDependency = artifact.LoadDependencies().Last();

            relativeDependency.Location.Should().Be(expectedDependencyPath);
        }
Exemple #2
0
        public void ShouldLoadDependencies(string format)
        {
            var deleteMap = new Dictionary <string, string> {
                { "json", "yaml" }, { "yaml", "json" }
            };

            // dependencyFiles temp dir is initialized each test by ctor,
            // so delete the dependency file NOT being tested
            File.Delete(Path.Combine(this.dependencyFiles, $"lambda-dependencies.{deleteMap[format]}"));

            var lambdaFunctionResource =
                this.LambdaFunctionResource("index.handler", "python3.6", this.dependencyFiles.FullPath);

            var mockOSInfo = new Mock <IOSInfo>();

            mockOSInfo.Setup(i => i.OSPlatform).Returns(OSPlatform.Windows);

            var artifact = new LambdaArtifact(
                new TestPathResolver(),
                lambdaFunctionResource,
                new TestLogger(this.output),
                mockOSInfo.Object,
                this.dependencyFiles);

            var dependencies = artifact.LoadDependencies();

            dependencies.Count.Should().Be(2);
        }