adding pester tests

This commit is contained in:
Aleksandr Chebotov
2020-09-22 18:22:15 +03:00
parent 56ea603436
commit 2148a2bd2f
5 changed files with 70 additions and 27 deletions

View File

@@ -325,7 +325,9 @@
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1"
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
"{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1",
"{{ template_dir }}/scripts/Installers/Configure-Shell.ps1"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
@@ -383,9 +385,7 @@
{
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1",
"{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1",
"{{ template_dir }}/scripts/Installers/Post-Deployment.ps1"
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1"
]
},
{

View File

@@ -324,7 +324,9 @@
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1"
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
"{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1",
"{{ template_dir }}/scripts/Installers/Configure-Shell.ps1"
],
"elevated_user": "{{user `install_user`}}",
"elevated_password": "{{user `install_password`}}"
@@ -383,9 +385,7 @@
"type": "powershell",
"scripts":[
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1",
"{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1",
"{{ template_dir }}/scripts/Installers/Run-NGen.ps1",
"{{ template_dir }}/scripts/Installers/Post-Deployment.ps1"
"{{ template_dir }}/scripts/Installers/Run-NGen.ps1"
]
},
{

View File

@@ -0,0 +1,19 @@
# Create shells folder
$shellPath = "C:\shells"
New-Item -Path $shellPath -ItemType Directory | Out-Null
# sh and bash <--> C:\msys64\usr\bin\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null
New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe" | Out-Null
# winbash <--> C:\Windows\System32\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null
# git4bash <--> C:\Program Files\Git\bin\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null
# MSYS2 <--> C:\msys64\usr\bin\bash.exe
New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe" | Out-Null
# Add shells to PATH
Add-MachinePathItem $shellPath

View File

@@ -1,19 +0,0 @@
# Create shells folder
$shellPath = "C:\shells"
$null = New-Item -Path $shellPath -ItemType Directory
# MSYS2 <--> C:\msys64\usr\bin\bash.exe
$null = New-Item -ItemType SymbolicLink -Path "$shellPath\msys2.exe" -Target "C:\msys64\usr\bin\bash.exe"
# sh and bash <--> C:\msys64\usr\bin\bash.exe
$null = New-Item -ItemType SymbolicLink -Path "$shellPath\bash.exe" -Target "C:\msys64\usr\bin\bash.exe"
$null = New-Item -ItemType SymbolicLink -Path "$shellPath\sh.exe" -Target "C:\msys64\usr\bin\sh.exe"
# winbash <--> C:\Windows\System32\bash.exe
$null = New-Item -ItemType SymbolicLink -Path "$shellPath\winbash.exe" -Target "$env:SystemRoot\System32\bash.exe"
# git4bash <--> C:\Program Files\Git\bin\bash.exe
$null = New-Item -ItemType SymbolicLink -Path "$shellPath\git4bash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe"
# Add shells to PATH
Add-MachinePathItem $shellPath

View File

@@ -0,0 +1,43 @@
Describe "Shell" {
$shellTestCases = @(
@{Name = "C:\shells\bash.exe"; Target = "C:\msys64\usr\bin\bash.exe"},
@{Name = "C:\shells\sh.exe"; Target = "C:\msys64\usr\bin\sh.exe"},
@{Name = "C:\shells\winbash.exe"; Target = "$env:SystemRoot\System32\bash.exe"},
@{Name = "C:\shells\git4bash.exe"; Target = "$env:ProgramFiles\Git\bin\bash.exe"},
@{Name = "C:\shells\msys2.exe"; Target = "C:\msys64\usr\bin\bash.exe"}
)
$pathTestCases = @(
@{Path = "C:\shells"},
@{Path = "C:\msys64\mingw64\bin"},
@{Path = "C:\msys64\usr\bin"}
)
It "Default bash.exe from MSYS2" {
(Get-Command bash).Path | Should -BeExactly "C:\shells\bash.exe"
}
It "Default sh.exe from MSYS2" {
(Get-Command sh).Path | Should -BeExactly "C:\shells\sh.exe"
}
It "Folder C:\shells exists" {
"C:\shells" | Should -Exist
}
It "C:\Windows\System32 before C:\msys64\mingw64\bin and C:\msys64\usr\bin" {
$path = $env:Path.Split(";").ToLower()
$indexOfSystem32 = $path.IndexOf("c:\windows\system32")
$path.IndexOf("c:\msys64\mingw64\bin") | Should -BeGreaterThan $indexOfSystem32
$path.IndexOf("c:\msys64\usr\bin") | Should -BeGreaterThan $indexOfSystem32
}
It "<Name> target to <Target>" -TestCases $shellTestCases {
(Get-Item $Name).Target | Should -BeExactly $Target
}
It "<Path> is in PATH" -TestCases $pathTestCases {
$env:Path.Split(";") | Should -Contain $Path
}
}