@@ -12,220 +12,73 @@ while(-not $mockingPath) {
12
12
}
13
13
. ($mockingPath | Select-Object - First 1 ).FullName
14
14
15
- InModuleScope Azs.InfrastructureInsights.Admin {
15
+ Describe " Alerts " - Tags @ ( ' Alert ' , ' InfrastructureInsightsAdmin ' ) {
16
16
17
- Describe " Alerts " - Tags @ ( ' Alert ' , ' InfrastructureInsightsAdmin ' ) {
17
+ . $PSScriptRoot \Common.ps1
18
18
19
- BeforeEach {
19
+ it " TestListAlerts " - Skip: $ ( ' TestListAlerts ' -in $ global :SkippedTests ) {
20
20
21
- function ValidateAlert {
21
+ $ global :TestName = ' TestListAlerts '
22
22
23
- param (
23
+ $Alerts = Get-AzsAlert - ResourceGroupName $ global :ResourceGroupName - Location $ global :Location
24
24
25
- [Parameter (Mandatory = $true )]
26
-
27
- $Alert
28
-
29
- )
30
-
31
- $Alert | Should Not Be $null
32
-
33
- # Resource
34
- $Alert.Id | Should Not Be $null
35
- $Alert.Location | Should Not Be $null
36
- $Alert.Name | Should Not Be $null
37
- $Alert.Type | Should Not Be $null
38
-
39
- # Alert
40
- $Alert.AlertId | Should Not Be $null
41
- $Alert.AlertProperty | Should Not Be $null
42
- $Alert.CreatedTimestamp | Should Not Be $null
43
- $Alert.Description | Should Not Be $null
44
- $Alert.FaultTypeId | Should Not Be $null
45
- $Alert.ImpactedResourceDisplayName | Should Not Be $null
46
- $Alert.ImpactedResourceId | Should Not Be $null
47
- $Alert.LastUpdatedTimestamp | Should Not Be $null
48
- $Alert.Remediation | Should Not Be $null
49
- $Alert.ResourceProviderRegistrationId | Should Not Be $null
50
- $Alert.Severity | Should Not Be $null
51
- $Alert.State | Should Not Be $null
52
- $Alert.Title | Should Not Be $null
53
- }
54
-
55
- function AssertAlertsAreSame {
56
- param (
57
- [Parameter (Mandatory = $true )]
58
- $Expected ,
59
-
60
- [Parameter (Mandatory = $true )]
61
- $Found
62
- )
63
-
64
- if ($Expected -eq $null ) {
65
- $Found | Should Be $null
66
- }
67
- else {
68
- $Found | Should Not Be $null
69
-
70
- # Resource
71
- $Found.Id | Should Be $Expected.Id
72
- $Found.Location | Should Be $Expected.Location
73
- $Found.Name | Should Be $Expected.Name
74
- $Found.Type | Should Be $Expected.Type
75
-
76
- # Alert
77
- $Found.AlertId | Should Be $Expected.AlertId
78
-
79
- if ($Expected.AlertProperties -eq $null ) {
80
-
81
- $Found.AlertProperties | Should Be $null
82
-
83
- }
84
-
85
- else {
86
-
87
- $Found.AlertProperties | Should Not Be $null
88
-
89
- $Found.AlertProperties.Count | Should Be $Expected.AlertProperties.Count
90
-
91
- }
92
-
93
-
94
-
95
- $Found.ClosedByUserAlias | Should Be $Expected.ClosedByUserAlias
96
-
97
- $Found.ClosedTimestamp | Should Be $Expected.ClosedTimestamp
98
-
99
- $Found.CreatedTimestamp | Should Be $Expected.CreatedTimestamp
100
-
101
-
102
-
103
- if ($Expected.Description -eq $null ) {
104
-
105
- $Found.Description | Should Be $null
106
-
107
- }
108
-
109
- else {
110
-
111
- $Found.Description | Should Not Be $null
112
-
113
- $Found.Description.Count | Should Be $Expected.Description.Count
114
-
115
- }
116
-
117
-
118
-
119
- $Found.FaultId | Should Be $Expected.FaultId
120
-
121
- $Found.FaultTypeId | Should Be $Expected.FaultTypeId
122
-
123
- $Found.ImpactedResourceDisplayName | Should Be $Expected.ImpactedResourceDisplayName
124
-
125
- $Found.ImpactedResourceId | Should Be $Expected.ImpactedResourceId
126
-
127
- $Found.LastUpdatedTimestamp | Should Be $Expected.LastUpdatedTimestamp
128
-
129
-
130
-
131
- if ($Expected.Remediation -eq $null ) {
132
-
133
- $Found.Remediation | Should Be $null
134
-
135
- }
136
-
137
- else {
138
-
139
- $Found.Remediation | Should Not Be $null
140
-
141
- $Found.Remediation.Count | Should Be $Expected.Remediation.Count
142
-
143
- }
144
-
145
-
146
-
147
- $Found.ResourceProviderRegistrationId | Should Be $Expected.ResourceProviderRegistrationId
148
-
149
- $Found.ResourceRegistrationId | Should Be $Expected.ResourceRegistrationId
150
-
151
- $Found.Severity | Should Be $Expected.Severity
152
-
153
- $Found.State | Should Be $Expected.State
154
-
155
- $Found.Title | Should Be $Expected.Title
156
-
157
-
158
-
159
- }
160
-
161
- }
162
-
163
- }
164
-
165
- it " TestListAlerts" - Skip:$ (' TestListAlerts' -in $global :SkippedTests ) {
166
-
167
- $global :TestName = ' TestListAlerts'
168
-
169
- $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $global :Location
170
-
171
- foreach ($Alert in $Alerts ) {
172
- ValidateAlert - Alert $Alert
173
- }
25
+ foreach ($Alert in $Alerts ) {
26
+ ValidateAlert - Alert $Alert
174
27
}
28
+ }
175
29
176
- it " TestGetAlert" - Skip:$ (' TestGetAlert' -in $global :SkippedTests ) {
30
+ it " TestGetAlert" - Skip:$ (' TestGetAlert' -in $global :SkippedTests ) {
177
31
178
- $global :TestName = ' TestGetAlert'
32
+ $global :TestName = ' TestGetAlert'
179
33
180
- $Regions = Get-AzsRegionHealth - ResourceGroupName $global :ResourceGroupName - Location $global :Location
34
+ $Regions = Get-AzsRegionHealth - ResourceGroupName $global :ResourceGroupName - Location $global :Location
181
35
182
- foreach ($Region in $Regions ) {
36
+ foreach ($Region in $Regions ) {
183
37
184
- $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $Region.Name
38
+ $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $Region.Name
185
39
186
- foreach ($Alert in $Alerts ) {
40
+ foreach ($Alert in $Alerts ) {
187
41
188
- $retrieved = Get-AzsAlert - Location $Region.Name - Name $Alert.AlertId
189
- AssertAlertsAreSame - Expected $Alert - Found $retrieved
190
- return
191
- }
42
+ $retrieved = Get-AzsAlert - Location $Region.Name - Name $Alert.AlertId
43
+ AssertAlertsAreSame - Expected $Alert - Found $retrieved
44
+ return
192
45
}
193
46
}
47
+ }
194
48
195
- it " TestGetAllAlerts" - Skip:$ (' TestGetAllAlerts' -in $global :SkippedTests ) {
49
+ it " TestGetAllAlerts" - Skip:$ (' TestGetAllAlerts' -in $global :SkippedTests ) {
196
50
197
- $global :TestName = ' TestGetAllAlerts'
51
+ $global :TestName = ' TestGetAllAlerts'
198
52
199
- $Regions = Get-AzsRegionHealth - ResourceGroupName $global :ResourceGroupName - Location $global :Location
53
+ $Regions = Get-AzsRegionHealth - ResourceGroupName $global :ResourceGroupName - Location $global :Location
200
54
201
- foreach ($Region in $Regions ) {
55
+ foreach ($Region in $Regions ) {
202
56
203
- $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $Region.Name
57
+ $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $Region.Name
204
58
205
- foreach ($Alert in $Alerts ) {
206
- $retrieved = Get-AzsAlert - Location $Region.Name - Name $Alert.AlertId
59
+ foreach ($Alert in $Alerts ) {
60
+ $retrieved = Get-AzsAlert - Location $Region.Name - Name $Alert.AlertId
207
61
208
- AssertAlertsAreSame - Expected $Alert - Found $retrieved
209
- }
62
+ AssertAlertsAreSame - Expected $Alert - Found $retrieved
210
63
}
211
64
}
65
+ }
212
66
213
- it " TestGetAllAlerts" - Skip:$ (' TestGetAllAlerts' -in $global :SkippedTests ) {
67
+ it " TestGetAllAlerts" - Skip:$ (' TestGetAllAlerts' -in $global :SkippedTests ) {
214
68
215
- $global :TestName = ' TestGetAllAlerts'
69
+ $global :TestName = ' TestGetAllAlerts'
216
70
217
- $Regions = Get-AzsRegionHealth - ResourceGroupName $global :ResourceGroupName - Location $global :Location
71
+ $Regions = Get-AzsRegionHealth - ResourceGroupName $global :ResourceGroupName - Location $global :Location
218
72
219
- foreach ($Region in $Regions ) {
73
+ foreach ($Region in $Regions ) {
220
74
221
- $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $Region.Name
75
+ $Alerts = Get-AzsAlert - ResourceGroupName $global :ResourceGroupName - Location $Region.Name
222
76
223
- foreach ($Alert in $Alerts ) {
224
- $retrieved = $Alert | Get-AzsAlert
225
- AssertAlertsAreSame - Expected $Alert - Found $retrieved
77
+ foreach ($Alert in $Alerts ) {
78
+ $retrieved = $Alert | Get-AzsAlert
79
+ AssertAlertsAreSame - Expected $Alert - Found $retrieved
226
80
227
- }
228
81
}
229
82
}
230
83
}
231
- }
84
+ }
0 commit comments