@@ -6,20 +6,22 @@ Describe 'WindowsPowerShell adapter resource tests - requires elevated permissio
66 BeforeAll {
77 if ($isWindows ) {
88 winrm quickconfig - quiet - force
9- }
10- $OldPSModulePath = $env: PSModulePath
11- $env: PSModulePath += [System.IO.Path ]::PathSeparator + $PSScriptRoot
9+ $OldPSModulePath = $env: PSModulePath
10+ $env: PSModulePath += [System.IO.Path ]::PathSeparator + $PSScriptRoot
1211
13- $winpsConfigPath = Join-path $PSScriptRoot " winps_resource.dsc.yaml"
14- if ($isWindows ) {
15- $cacheFilePath_v5 = Join-Path $env: LocalAppData " dsc" " WindowsPSAdapterCache.json"
12+ $winpsConfigPath = Join-path $PSScriptRoot " winps_resource.dsc.yaml"
13+ if ($isWindows ) {
14+ $cacheFilePath_v5 = Join-Path $env: LocalAppData " dsc" " WindowsPSAdapterCache.json"
15+ }
1616 }
1717 }
1818 AfterAll {
19- $env: PSModulePath = $OldPSModulePath
19+ if ($isWindows ) {
20+ $env: PSModulePath = $OldPSModulePath
2021
21- # Remove after all the tests are done
22- Remove-Module $script :winPSModule - Force - ErrorAction Ignore
22+ # Remove after all the tests are done
23+ Remove-Module $script :winPSModule - Force - ErrorAction Ignore
24+ }
2325 }
2426
2527 BeforeEach {
@@ -161,7 +163,7 @@ resources:
161163 - "[resourceId('Microsoft.Windows/WindowsPowerShell', 'File')]"
162164 - name: TestPSRepository
163165 type: PSTestModule/TestPSRepository
164- properties:
166+ properties:
165167 Name: NuGet
166168 dependsOn:
167169 - "[resourceId('Microsoft.Windows/WindowsPowerShell', 'File')]"
@@ -201,7 +203,7 @@ resources:
201203 type: PsDesiredStateConfiguration/Service
202204 properties:
203205 Name: Spooler
204- State: $SecondState
206+ State: $SecondState
205207"@
206208
207209 $inDesiredState = if ($FirstState -eq $SecondState ) {
@@ -242,11 +244,11 @@ resources:
242244 # Instead of calling dsc.exe we call the cmdlet directly to be able to test the output and mocks
243245 $resourceObject = Get-DscResourceObject - jsonInput $jsonInput
244246 $cacheEntry = Invoke-DscCacheRefresh - Module PSDesiredStateConfiguration
245-
247+
246248 $out = Invoke-DscOperation - Operation Test - DesiredState $resourceObject - dscResourceCache $cacheEntry
247249 $LASTEXITCODE | Should - Be 0
248250 $out.properties.InDesiredState.InDesiredState | Should - Be $false
249-
251+
250252 Should - Invoke - CommandName ConvertTo-SecureString - Exactly - Times 1 - Scope It
251253 }
252254
@@ -261,7 +263,7 @@ resources:
261263 Credential:
262264 UserName: 'User'
263265 OtherProperty: 'Password'
264- "@
266+ "@
265267 # Compared to PowerShell we use test here as it filters out the properties
266268 $out = dsc config test - i $yaml 2>&1 | Out-String
267269 $LASTEXITCODE | Should - Be 2
@@ -339,7 +341,7 @@ class PSClassResource {
339341 }
340342
341343 [void] Set() {
342-
344+
343345 }
344346
345347 static [PSClassResource[]] Export()
@@ -374,23 +376,23 @@ class PSClassResource {
374376 }
375377
376378 It ' Get works with class-based PS DSC resources' - Skip:(! $IsWindows ) {
377-
379+
378380 $out = dsc resource get - r PSClassResource/ PSClassResource -- input (@ {Name = ' TestName' } | ConvertTo-Json ) | ConvertFrom-Json
379381 $LASTEXITCODE | Should - Be 0
380382 $out.actualState.Name | Should - Be ' TestName'
381- $propCount = $out.actualState | Get-Member - MemberType NoteProperty
383+ $propCount = $out.actualState | Get-Member - MemberType NoteProperty
382384 $propCount.Count | Should - Be 1 # Only the DscProperty should be returned
383385 }
384386
385387 It ' Set works with class-based PS DSC resources' - Skip:(! $IsWindows ) {
386-
388+
387389 $out = dsc resource set - r PSClassResource/ PSClassResource -- input (@ {Name = ' TestName' } | ConvertTo-Json ) | ConvertFrom-Json
388390 $LASTEXITCODE | Should - Be 0
389391 $out.afterstate.InDesiredState | Should - Be $true
390392 }
391393
392394 It ' Export works with class-based PS DSC resources' - Skip:(! $IsWindows ) {
393-
395+
394396 $out = dsc resource export - r PSClassResource/ PSClassResource | ConvertFrom-Json
395397 $LASTEXITCODE | Should - Be 0
396398 $out | Should -Not - BeNullOrEmpty
0 commit comments