@@ -20,11 +20,10 @@ Describe "BOSH.Sysprep" {
2020 Mock - ModuleName BOSH.Sysprep Stop-Computer { }
2121 Mock - ModuleName BOSH.Sysprep Start-Process { }
2222
23- $lgpoInstalled = $True
2423 Mock - ModuleName BOSH.Sysprep - CommandName Test-Path - ParameterFilter {
2524 if ($Path -eq " C:\Windows\LGPO.exe" )
2625 {
27- return $lgpoInstalled
26+ return $True
2827 }
2928 }
3029 }
@@ -52,7 +51,7 @@ Describe "BOSH.Sysprep" {
5251 Mock - ModuleName BOSH.Sysprep Enable-AWS - Sysprep { }
5352 }
5453
55- It " handles other OS' " {
54+ It " updates launchconfig.json, unattended.xml and calls Enable-AWS-Sysprep " {
5655 { Invoke-Sysprep - Iaas " aws" } | Should -Not - Throw
5756
5857 Should - Invoke - ModuleName BOSH.Sysprep - CommandName Update-AWS - LaunchConfigJSON
@@ -80,14 +79,18 @@ Describe "BOSH.Sysprep" {
8079 It " skips local policy update if -SkipLGPO is set" {
8180 { Invoke-Sysprep - Iaas " aws" - SkipLGPO } | Should -Not - Throw
8281
83- Should - Invoke - ModuleName BOSH.Sysprep `
84- - CommandName Enable-LocalSecurityPolicy - Times 0
82+ Should - Invoke - ModuleName BOSH.Sysprep - CommandName Enable-LocalSecurityPolicy - Times 0
8583 }
8684 }
8785
8886 Context " if LGPO.exe is not found" {
8987 BeforeEach {
90- $lgpoInstalled = $False
88+ Mock - ModuleName BOSH.Sysprep - CommandName Test-Path - ParameterFilter {
89+ if ($Path -eq " C:\Windows\LGPO.exe" )
90+ {
91+ return $True
92+ }
93+ }
9194 }
9295
9396 It " throws an error" {
@@ -140,14 +143,18 @@ Describe "BOSH.Sysprep" {
140143 It " skips local policy update if -SkipLGPO is set" {
141144 { Invoke-Sysprep - Iaas " gcp" - SkipLGPO } | Should -Not - Throw
142145
143- Should - Invoke - ModuleName BOSH.Sysprep `
144- - CommandName Enable-LocalSecurityPolicy - Times 0
146+ Should - Invoke - ModuleName BOSH.Sysprep - CommandName Enable-LocalSecurityPolicy - Times 0
145147 }
146148 }
147149
148150 Context " if LGPO.exe is not found" {
149151 BeforeEach {
150- $lgpoInstalled = $False
152+ Mock - ModuleName BOSH.Sysprep - CommandName Test-Path - ParameterFilter {
153+ if ($Path -eq " C:\Windows\LGPO.exe" )
154+ {
155+ return $True
156+ }
157+ }
151158 }
152159
153160 It " throws an error" {
@@ -209,14 +216,18 @@ Describe "BOSH.Sysprep" {
209216 It " skips local policy update if -SkipLGPO is set" {
210217 { Invoke-Sysprep - Iaas " vsphere" - SkipLGPO } | Should -Not - Throw
211218
212- Should - Invoke - ModuleName BOSH.Sysprep `
213- - CommandName Enable-LocalSecurityPolicy - Times 0
219+ Should - Invoke - ModuleName BOSH.Sysprep - CommandName Enable-LocalSecurityPolicy - Times 0
214220 }
215221 }
216222
217223 Context " if LGPO.exe is not found" {
218224 BeforeEach {
219- $lgpoInstalled = $False
225+ Mock - ModuleName BOSH.Sysprep - CommandName Test-Path - ParameterFilter {
226+ if ($Path -eq " C:\Windows\LGPO.exe" )
227+ {
228+ return $True
229+ }
230+ }
220231 }
221232
222233 It " throws an error" {
0 commit comments