Skip to content

Commit 305c791

Browse files
committed
Merge pull request Azure#1562 from stankovski/clu
Misc test fixes
2 parents 39b1a20 + c9d5165 commit 305c791

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

examples/lib/loginUser.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/bin/bash
2-
echo "Logging in as user"
32
azure account add -u "$azureUser" -p "$password" -s "$subscription"

examples/lib/testrunner.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export location="westus"
66
export CmdletSessionID=1010
77
export MSYS_NO_PATHCONV=1
88

9+
echo "Logging in as user"
910
. $BASEDIR/loginUser.sh
1011

1112
for d in $( ls $BASEDIR/.. --ignore=lib ); do

src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ public class ExampleScriptRunner
3939
ResourceManagementClient _client;
4040
const string DefaultLocation = "westus";
4141
const string ResourceGroupNameKey = "groupName";
42-
const string locationKey = "location";
42+
const string LocationKey = "location";
43+
const string BaseDir = "BASEDIR";
4344
const string SessionKey = "CmdletSessionID";
44-
const string storageAccountTypeKey = "storageAccountType";
45-
const string storageAccountNameKey = "storageAccountName";
45+
const string StorageAccountTypeKey = "storageAccountType";
46+
const string StorageAccountNameKey = "storageAccountName";
4647
const string DefaultStorageAccountType = "Standard_GRS";
4748

4849
public ExampleScriptRunner(string sessionId) : this(new Random(), sessionId)
@@ -106,11 +107,12 @@ public string RunScript(string testName)
106107
DeployTemplate(deploymentTemplatePath, _resourceGroupName);
107108
}
108109

110+
process.EnvironmentVariables[BaseDir] = testDirectory;
109111
process.EnvironmentVariables[SessionKey] = _sessionId;
110112
process.EnvironmentVariables[ResourceGroupNameKey] = _resourceGroupName;
111-
process.EnvironmentVariables[locationKey] = DefaultLocation;
112-
process.EnvironmentVariables[storageAccountTypeKey] = DefaultStorageAccountType;
113-
process.EnvironmentVariables[storageAccountNameKey] = _storageAccountName;
113+
process.EnvironmentVariables[LocationKey] = DefaultLocation;
114+
process.EnvironmentVariables[StorageAccountTypeKey] = DefaultStorageAccountType;
115+
process.EnvironmentVariables[StorageAccountNameKey] = _storageAccountName;
114116
foreach (var helper in _context.EnvironmentHelpers)
115117
{
116118
helper.TrySetupScriptEnvironment(_context, _clientFactory, process.EnvironmentVariables);

src/CLU/Commands.Common.ScenarioTest/ProcessHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,16 @@ private void SetEnvironmentVariables(ProcessStartInfo startInfo)
173173

174174
private void ProcessError(object sender, DataReceivedEventArgs e)
175175
{
176-
Logger.Instance.WriteError(e.Data);
176+
if (e.Data != null)
177+
{
178+
Logger.Instance.WriteError(e.Data);
179+
}
177180
}
178181

179182
private void ProcessOutput(object sender, DataReceivedEventArgs e)
180183
{
181-
Logger.Instance.WriteMessage(e.Data);
182184
_processOutput.Append(e.Data);
185+
Logger.Instance.WriteMessage(e.Data);
183186
}
184187

185188
private void EndProcess()

src/CLU/Commands.Common.ScenarioTest/ScenarioTestFixture.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Models;
1717
using Microsoft.Azure.Commands.Common.ScenarioTest;
1818
using Microsoft.Azure.Commands.Models;
19-
using Moq.Protected;
2019
using Newtonsoft.Json;
2120

2221
namespace Microsoft.Azure.Commands.Common.ScenarioTest
@@ -34,6 +33,10 @@ public ScenarioTestFixture()
3433
var helper = GetRunner("lib");
3534
var profileText = helper.RunScript(credentials.LoginScriptName);
3635
var profile = JsonConvert.DeserializeObject<PSAzureProfile>(profileText);
36+
if (profile == null)
37+
{
38+
throw new ArgumentOutOfRangeException(nameof(profile), $"Deserialized profile is null: `{profileText}`");
39+
}
3740
AzureContext = (AzureContext) (profile.Context);
3841
}
3942

src/CLU/Commands.Common.ScenarioTest/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"Commands.Common": "",
2121
"Commands.Common.Authentication": "",
2222
"Commands.ResourceManager.Common": "",
23-
"Commands.ScenarioTests.ResourceManager.Common": "",
2423
"Microsoft.Azure.Commands.Profile": "",
2524
"Microsoft.Azure.Management.Resources": "3.3.0-preview",
2625
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",

0 commit comments

Comments
 (0)