Exemplo n.º 1
0
 public void LinuxDedicatedPlan()
 {
     using (new TestScopedEnvironmentVariable("WEBSITE_INSTANCE_ID", "wii"))
     {
         IEnvironment env = TestMockedEnvironment.GetMockedEnvironment();
         Assert.False(env.IsOnLinuxConsumption);
     }
 }
Exemplo n.º 2
0
 public void LinuxConsumptionPlan()
 {
     using(new TestScopedEnvironmentVariable("CONTAINER_NAME", "cn"))
     {
         IEnvironment env = TestMockedEnvironment.GetMockedEnvironment();
         Assert.True(env.IsOnLinuxConsumption);
     }
 }
Exemplo n.º 3
0
 public void InvalidLinuxPlan()
 {
     using (new TestScopedEnvironmentVariable("CONTAINER_NAME", "cn"))
     using (new TestScopedEnvironmentVariable("WEBSITE_INSTANCE_ID", "wii"))
     {
         IEnvironment env = TestMockedEnvironment.GetMockedEnvironment();
         Assert.False(env.IsOnLinuxConsumption);
     }
 }
 public void OryxArgumentShouldBeFunctionApp()
 {
     using (new TestScopedEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "PYTHON"))
         using (new TestScopedEnvironmentVariable("FUNCTIONS_EXTENSION_VERSION", "~2"))
         {
             IEnvironment   ienv = TestMockedEnvironment.GetMockedEnvironment();
             IOryxArguments args = OryxArgumentsFactory.CreateOryxArguments(ienv);
             Assert.IsType <FunctionAppOryxArguments>(args);
         }
 }
 public void OryxArgumentShouldBeLinuxConsumption()
 {
     using (new TestScopedEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "PYTHON"))
         using (new TestScopedEnvironmentVariable("FUNCTIONS_EXTENSION_VERSION", "~2"))
             using (new TestScopedEnvironmentVariable("SCM_RUN_FROM_PACKAGE", "http://microsoft.com"))
             {
                 IEnvironment   ienv = TestMockedEnvironment.GetMockedEnvironment();
                 IOryxArguments args = OryxArgumentsFactory.CreateOryxArguments(ienv);
                 Assert.IsType <LinuxConsumptionFunctionAppOryxArguments>(args);
             }
 }
        public void BuildCommandForAppService()
        {
            DeploymentContext deploymentContext = new DeploymentContext()
            {
                OutputPath = "outputpath"
            };
            IEnvironment   ienv    = TestMockedEnvironment.GetMockedEnvironment();
            IOryxArguments args    = OryxArgumentsFactory.CreateOryxArguments(ienv);
            string         command = args.GenerateOryxBuildCommand(deploymentContext);

            Assert.Equal(@"oryx build outputpath -o outputpath", command);
        }
Exemplo n.º 7
0
        public void ReturnsDeploymentsPath()
        {
            const string somePath = "/some-path";

            var fileSystem = new Mock <IFileSystem>(MockBehavior.Strict);
            var directory  = new Mock <DirectoryBase>(MockBehavior.Strict);

            directory.Setup(d => d.Exists(It.IsAny <string>())).Returns(true);
            fileSystem.SetupGet(f => f.Directory).Returns(directory.Object);

            using (new MockFileSystem(fileSystem.Object))
            {
                var fileSystemPathProvider = new Mock <IFileSystemPathProvider>(MockBehavior.Strict);

                // Configure an override for deployments path
                fileSystemPathProvider.Setup(f => f.TryGetDeploymentsPath(out It.Ref <string> .IsAny)).
                Callback(new GetDeploymentPathCallback((out string path) =>
                {
                    path = somePath;
                })).Returns(new GetDeploymentPathReturn((out string path) =>
                {
                    path = somePath;
                    return(true);
                }));

                IEnvironment env = TestMockedEnvironment.GetMockedEnvironment(string.Empty, string.Empty, string.Empty,
                                                                              string.Empty, string.Empty, fileSystemPathProvider.Object);
                Assert.Equal(somePath, env.DeploymentsPath);
                fileSystemPathProvider.Reset();

                // Return false from filesystempath provider so the default deployments path is returned
                fileSystemPathProvider.Setup(f => f.TryGetDeploymentsPath(out It.Ref <string> .IsAny)).
                Callback(new GetDeploymentPathCallback((out string path) =>
                {
                    path = somePath;
                })).Returns(new GetDeploymentPathReturn((out string path) =>
                {
                    path = somePath;
                    return(false);
                }));

                env = TestMockedEnvironment.GetMockedEnvironment(string.Empty, string.Empty, string.Empty,
                                                                 string.Empty, string.Empty, fileSystemPathProvider.Object);
                Assert.NotEqual(somePath, env.DeploymentsPath);
                fileSystemPathProvider.Reset();

                // Uses default path when no override is set
                env = TestMockedEnvironment.GetMockedEnvironment();
                Assert.NotEqual(somePath, env.DeploymentsPath);
            }
        }
        public void OryxArgumentSkipKuduSync(bool expectedSkipKuduSync, params string[] varargs)
        {
            IDictionary <string, string> env = new Dictionary <string, string>();

            for (int i = 0; i < varargs.Length; i += 2)
            {
                env.Add(varargs[i], varargs[i + 1]);
            }

            using (new TestScopedEnvironmentVariable(env))
            {
                IEnvironment   ienv = TestMockedEnvironment.GetMockedEnvironment();
                IOryxArguments args = OryxArgumentsFactory.CreateOryxArguments(ienv);
                Assert.Equal(expectedSkipKuduSync, args.SkipKuduSync);
            }
        }
        public void BuildCommandForLinuxConsumptionFunctionApp()
        {
            DeploymentContext deploymentContext = new DeploymentContext()
            {
                RepositoryPath = "repositorypath"
            };

            using (new TestScopedEnvironmentVariable("FUNCTIONS_EXTENSION_VERSION", "~2"))
                using (new TestScopedEnvironmentVariable("SCM_RUN_FROM_PACKAGE", "http://microsoft.com"))
                {
                    IEnvironment   ienv    = TestMockedEnvironment.GetMockedEnvironment();
                    IOryxArguments args    = OryxArgumentsFactory.CreateOryxArguments(ienv);
                    string         command = args.GenerateOryxBuildCommand(deploymentContext);
                    Assert.Equal(@"oryx build repositorypath -o repositorypath", command);
                }
        }
Exemplo n.º 10
0
        public void BuildCommandForFunctionApp()
        {
            DeploymentContext deploymentContext = new DeploymentContext()
            {
                OutputPath    = "outputpath",
                BuildTempPath = "buildtemppath"
            };

            using (new TestScopedEnvironmentVariable("FUNCTIONS_EXTENSION_VERSION", "~2"))
            {
                IEnvironment   ienv    = TestMockedEnvironment.GetMockedEnvironment();
                IOryxArguments args    = OryxArgumentsFactory.CreateOryxArguments(ienv);
                string         command = args.GenerateOryxBuildCommand(deploymentContext);
                Assert.Equal(@"oryx build outputpath -o outputpath -i buildtemppath", command);
            }
        }
Exemplo n.º 11
0
        public void BuildCommandForPythonFunctionApp()
        {
            DeploymentContext deploymentContext = new DeploymentContext()
            {
                OutputPath    = "outputpath",
                BuildTempPath = "buildtemppath"
            };

            using (new TestScopedEnvironmentVariable("FUNCTIONS_EXTENSION_VERSION", "~2"))
                using (new TestScopedEnvironmentVariable("FUNCTIONS_WORKER_RUNTIME", "python"))
                {
                    IEnvironment   ienv    = TestMockedEnvironment.GetMockedEnvironment();
                    IOryxArguments args    = OryxArgumentsFactory.CreateOryxArguments(ienv);
                    string         command = args.GenerateOryxBuildCommand(deploymentContext);
                    Assert.Equal(@"oryx build outputpath -o outputpath --platform python --platform-version 3.6 -i buildtemppath -p packagedir=.python_packages\lib\python3.6\site-packages", command);
                }
        }
Exemplo n.º 12
0
 public void UnsetLinuxPlan()
 {
     IEnvironment env = TestMockedEnvironment.GetMockedEnvironment();
     Assert.False(env.IsOnLinuxConsumption);
 }