Skip to content

Commit 58728f1

Browse files
committed
Pester: extract OS constant in tests
1 parent e976b0e commit 58728f1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/BOSH.Sysprep/BOSH.Sysprep.Tests.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ BeforeAll {
33
Import-Module ../BOSH.Utils/BOSH.Utils.psm1
44
Import-Module ../BOSH.Agent/BOSH.Agent.psm1
55

6+
$OsVersion = "windows2019"
67

78
InModuleScope BOSH.Sysprep {
89
function GCESysprep
@@ -28,13 +29,13 @@ Describe "BOSH.Sysprep" {
2829
Mock -ModuleName BOSH.Sysprep Stop-Computer { }
2930
Mock -ModuleName BOSH.Sysprep Start-Process { }
3031

31-
Mock -ModuleName BOSH.Sysprep -CommandName Get-OSVersion { "windows2019" }
32+
Mock -ModuleName BOSH.Sysprep -CommandName Get-OSVersion { $OsVersion }
3233
Mock -ModuleName BOSH.Sysprep -CommandName Enable-LocalSecurityPolicy { }
3334
}
3435

3536
Context "when not provided an IaaS" {
3637
It "throws" {
37-
{ Invoke-Sysprep -OsVersion "windows2019" } | Should -Throw "Provide the IaaS this stemcell will be used for"
38+
{ Invoke-Sysprep -OsVersion $OsVersion } | Should -Throw "Provide the IaaS this stemcell will be used for"
3839
}
3940
}
4041

@@ -44,7 +45,7 @@ Describe "BOSH.Sysprep" {
4445
}
4546

4647
It "throws" {
47-
{ Invoke-Sysprep -IaaS "OpenShift" -SkipLGPO -OsVersion "windows2019" } | Should -Throw "Invalid IaaS 'OpenShift' supported platforms are: AWS, Azure, GCP and Vsphere"
48+
{ Invoke-Sysprep -IaaS "OpenShift" -SkipLGPO -OsVersion $OsVersion } | Should -Throw "Invalid IaaS 'OpenShift' supported platforms are: AWS, Azure, GCP and Vsphere"
4849
}
4950
}
5051

@@ -334,7 +335,7 @@ Describe "BOSH.Sysprep" {
334335

335336
Describe "Enable-LocalSecurityPolicy" {
336337
BeforeEach {
337-
Mock -ModuleName BOSH.Sysprep -CommandName Get-OSVersion { "windows2019" }
338+
Mock -ModuleName BOSH.Sysprep -CommandName Get-OSVersion { $OsVersion }
338339

339340
$expectedPolicyDir = Join-Path $PSScriptRoot "cis-merge-2019"
340341
$domainSysVolDir = "$expectedPolicyDir/DomainSysvol"

0 commit comments

Comments
 (0)