Example #1
0
        public void ReturnsApplicationName()
        {
            var          testSystemEnvironment = new TestSystemEnvironment();
            const string placeholderSiteName   = "placeholder-site-name";

            testSystemEnvironment.SetEnvironmentVariable(Constants.ContainerName, "c1"); // linux consumption
            testSystemEnvironment.SetEnvironmentVariable(Constants.WebsiteSiteName, placeholderSiteName);
            var serverConfiguration = new ServerConfiguration(testSystemEnvironment);

            Assert.Equal(placeholderSiteName, serverConfiguration.ApplicationName);

            // Updating the env variable should reflect immediately. since sitename is not cached
            const string testSite2 = "test-site-2";

            testSystemEnvironment.SetEnvironmentVariable(Constants.WebsiteSiteName, testSite2);
            Assert.Equal(testSite2, serverConfiguration.ApplicationName);
        }
        public async Task MountsOnLinuxConsumptionOnly()
        {
            // Container name will be null on non-Linux consumption environments
            _systemEnvironment.SetEnvironmentVariable(Constants.ContainerName, null);

            var meshPersistentFileSystem =
                new MeshPersistentFileSystem(_systemEnvironment, _client.Object, _storageClient.Object);

            Assert.False(meshPersistentFileSystem.GetStatus(out string _));

            var mountResult = await meshPersistentFileSystem.MountFileShare();

            Assert.False(mountResult);

            Assert.False(meshPersistentFileSystem.GetStatus(out var statusMessage));
            Assert.True(statusMessage.Contains("only supported on Linux consumption environment", StringComparison.Ordinal));

            Assert.True(string.IsNullOrEmpty(meshPersistentFileSystem.GetDeploymentsPath()));

            _storageClient.Verify(s => s.CreateFileShare(It.IsAny <string>(), ConnectionString, It.IsAny <string>()),
                                  Times.Never);
            _client.Verify(c => c.MountCifs(ConnectionString, It.IsAny <string>(), Constants.KuduFileShareMountPath),
                           Times.Never);
        }