public virtual PsDeploymentScriptLog GetDeploymentScriptLog(string scriptName, string resourceGroupName) { var deploymentScriptLog = DeploymentScriptsClient.DeploymentScripts.GetLogsDefault(resourceGroupName, scriptName); return(PsDeploymentScriptLog.ToPsDeploymentScriptLog(deploymentScriptLog)); }
public void SaveDeploymentScriptLogToDisk() { PsDeploymentScriptLog expected = new PsDeploymentScriptLog { Id = $"subscriptions/00000000-dead-beef-48e9-000000000000/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{deploymentScriptName}/logs/default", Log = "This is the log content", Name = "default" }; var TestLogPath = "TestLogPath"; var expectedOutputPath = Path.Combine(TestLogPath, $"{deploymentScriptName}.txt"); deploymentScriptsMockClient .Setup(f => f.GetDeploymentScriptLog(deploymentScriptName, resourceGroupName, 0)) .Returns(expected); commandRuntimeMock.Setup(f => f.ShouldProcess(It.IsAny <string>(), It.IsAny <string>())).Returns(true); var dataStore = new MockDataStore(); AzureSession.Instance.DataStore = dataStore; dataStore.CreateDirectory(TestLogPath); // Read should not throw Assert.True(dataStore.DirectoryExists(TestLogPath)); cmdlet.ResourceGroupName = resourceGroupName; cmdlet.Name = deploymentScriptName; cmdlet.OutputPath = TestLogPath; cmdlet.Tail = 0; cmdlet.SetParameterSet("SaveDeploymentScriptLogByName"); // Test cmdlet.ExecuteCmdlet(); //Assert Assert.Equal(expected.DeploymentScriptName, deploymentScriptName); Assert.Equal(expected.Log, dataStore.ReadFileAsText(expectedOutputPath)); Assert.True(dataStore.FileExists(expectedOutputPath)); }