File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
DSCResources/MSFT_WaitForAny Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ function Get-TargetResource
29
29
[Uint32 ] $ThrottleLimit = 32 # Powershell New-CimSession default throttle value
30
30
)
31
31
32
+ Write-Verbose " In Get-TargetResource"
33
+
32
34
Import-Module $PSScriptRoot \..\..\PSDSCxMachine.psm1
33
35
34
36
$b = @ {" hash" = " table" }
@@ -75,10 +77,14 @@ function Set-TargetResource
75
77
[Uint32 ] $ThrottleLimit = 32 # Powershell New-CimSession default throttle value
76
78
)
77
79
80
+ Write-Verbose " In Set-TargetResource"
81
+
78
82
Import-Module $PSScriptRoot \..\..\PSDSCxMachine.psm1
79
83
80
84
if ($PSBoundParameters [" Verbose" ])
81
85
{
86
+ Write-Verbose " Calling xMachine with Verbose parameter"
87
+
82
88
PSDSCxMachine\Set-_InternalPSDscXMachineTR `
83
89
- RemoteResourceId $ResourceName `
84
90
- RemoteMachine $NodeName `
@@ -130,6 +136,8 @@ function Test-TargetResource
130
136
[Uint32 ] $ThrottleLimit = 32 # Powershell New-CimSession default throttle value
131
137
)
132
138
139
+ Write-Verbose " In Test-TargetResource"
140
+
133
141
Import-Module $PSScriptRoot \..\..\PSDSCxMachine.psm1
134
142
135
143
$a = $true
Original file line number Diff line number Diff line change
1
+ Import-Module PSScriptAnalyzer
2
+
3
+ $violationMessage = " There is no call to Write-Verbose in DSC function ‘Set-TargetResource’. If you are using Write-Verbose in a helper function, suppress this rule application."
4
+ $violationName = " PSDSCUseVerboseMessageInDSCResource"
5
+ $directory = Split-Path - Parent $MyInvocation.MyCommand.Path
6
+ $violations = Invoke-ScriptAnalyzer $directory \DSCResources\MSFT_WaitForAll\MSFT_WaitForAll.psm1 | Where-Object {$_.RuleName -eq $violationName }
7
+ $noViolations = Invoke-ScriptAnalyzer $directory \DSCResources\MSFT_WaitForAny\MSFT_WaitForAny.psm1 | Where-Object {$_.RuleName -eq $violationName }
8
+ $noClassViolations = Invoke-ScriptAnalyzer - ErrorAction SilentlyContinue $directory \DSCResources\MyDscResource\MyDscResource.psm1 | Where-Object {$_.RuleName -eq $violationName }
9
+
10
+ Describe " UseVerboseMessageInDSCResource" {
11
+ Context " When there are violations" {
12
+ It " has 2 Verbose Message violations" {
13
+ $violations.Count | Should Be 2
14
+ }
15
+
16
+ It " has the correct description message" {
17
+ $violations [0 ].Message | Should Match $violationMessage
18
+ }
19
+ }
20
+
21
+ Context " When there are no violations" {
22
+ It " returns no violations" {
23
+ $noViolations.Count | Should Be 0
24
+ }
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments