Skip to content

Commit 162f282

Browse files
committed
Add debug stream test
1 parent 4236664 commit 162f282

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-2
lines changed

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public abstract class AzurePSCmdlet : PSCmdlet, IDisposable
3838
protected readonly ConcurrentQueue<string> _debugMessages;
3939

4040
private RecordingTracingInterceptor _httpTracingInterceptor;
41-
41+
4242
private DebugStreamTraceListener _adalListener;
4343
protected static AzurePSDataCollectionProfile _dataCollectionProfile = null;
4444
protected static string _errorRecordFolderPath = null;
@@ -507,7 +507,7 @@ public void Dispose()
507507
{
508508
FlushDebugMessages();
509509
}
510-
catch (Exception) { }
510+
catch { }
511511
Dispose(true);
512512
GC.SuppressFinalize(this);
513513
}

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceGroupTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,11 @@ public void TestRemoveDeployment()
8787
{
8888
ResourcesController.NewInstance.RunPsTest("Test-RemoveDeployment");
8989
}
90+
91+
[Fact]
92+
public void TestGetNonExistingResourceGroupWithDebugStream()
93+
{
94+
ResourcesController.NewInstance.RunPsTest("Test-GetNonExistingResourceGroupWithDebugStream");
95+
}
9096
}
9197
}

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceGroupTests.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,16 @@ function Test-FindResourceGroup
305305
Clean-ResourceGroup $rgname
306306
Clean-ResourceGroup $rgname2
307307
}
308+
}
309+
310+
<#
311+
.SYNOPSIS
312+
Tests remove non exist resource group and debug stream gets printed
313+
#>
314+
function Test-GetNonExistingResourceGroupWithDebugStream
315+
{
316+
$ErrorActionPreference="Continue"
317+
$output = $(Get-AzureRmResourceGroup -Name "InvalidNonExistRocks" -Debug) 2>&1 5>&1 | Out-String
318+
$ErrorActionPreference="Stop"
319+
Assert-True { $output -Like "*============================ HTTP RESPONSE ============================*" }
308320
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/subscriptions/3ca49042-782a-4cc9-89b5-ee1b487fe115/resourcegroups/InvalidNonExistRocks?api-version=2014-04-01-preview",
5+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvM2NhNDkwNDItNzgyYS00Y2M5LTg5YjUtZWUxYjQ4N2ZlMTE1L3Jlc291cmNlZ3JvdXBzL0ludmFsaWROb25FeGlzdFJvY2tzP2FwaS12ZXJzaW9uPTIwMTQtMDQtMDEtcHJldmlldw==",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"User-Agent": [
10+
"Microsoft.Azure.Management.Resources.ResourceManagementClient/2.0.0.0"
11+
]
12+
},
13+
"ResponseBody": "{\r\n \"error\": {\r\n \"code\": \"ResourceGroupNotFound\",\r\n \"message\": \"Resource group 'InvalidNonExistRocks' could not be found.\"\r\n }\r\n}",
14+
"ResponseHeaders": {
15+
"Content-Length": [
16+
"112"
17+
],
18+
"Content-Type": [
19+
"application/json; charset=utf-8"
20+
],
21+
"Expires": [
22+
"-1"
23+
],
24+
"Pragma": [
25+
"no-cache"
26+
],
27+
"x-ms-failure-cause": [
28+
"gateway"
29+
],
30+
"x-ms-ratelimit-remaining-subscription-reads": [
31+
"14999"
32+
],
33+
"x-ms-request-id": [
34+
"3633e6fd-16ca-4f0d-830f-bfa2eacf42f9"
35+
],
36+
"x-ms-correlation-request-id": [
37+
"3633e6fd-16ca-4f0d-830f-bfa2eacf42f9"
38+
],
39+
"x-ms-routing-request-id": [
40+
"WESTUS:20151125T215815Z:3633e6fd-16ca-4f0d-830f-bfa2eacf42f9"
41+
],
42+
"Strict-Transport-Security": [
43+
"max-age=31536000; includeSubDomains"
44+
],
45+
"Cache-Control": [
46+
"no-cache"
47+
],
48+
"Date": [
49+
"Wed, 25 Nov 2015 21:58:14 GMT"
50+
]
51+
},
52+
"StatusCode": 404
53+
}
54+
],
55+
"Names": {},
56+
"Variables": {
57+
"SubscriptionId": "3ca49042-782a-4cc9-89b5-ee1b487fe115",
58+
"TenantId": "1449d5b7-8a83-47db-ae4c-9b03e888bad0",
59+
"Domain": "rbactest.onmicrosoft.com"
60+
}
61+
}

0 commit comments

Comments
 (0)