PowerShell/test/powershell/Provider/Pester.AutomountedDrives.Tests.ps1
Steve Lee 2cc091115b Rename powershell.exe to pwsh.exe (#5101)
- Rename powershell.exe to pwsh.exe
- Fixe appveyor.psm1
- Update MSI to include 'pwsh' in path and app paths
- Revert change for hyper-v powershell direct
- Update names in packaging.psm1.
- Fix check for SxS
2017-10-17 17:25:11 -07:00

56 lines
2.4 KiB
PowerShell

<############################################################################################
# File: Pester.AutomountedDrives.Tests.ps1
# Pester.AutomountedDrives.Tests suite contains Tests that are
# used for validating automounted PowerShell drives.
############################################################################################>
$script:TestSourceRoot = $PSScriptRoot
Describe "Test suite for validating automounted PowerShell drives" -Tags @('Feature', 'Slow', 'RequireAdminOnWindows') {
BeforeAll {
$powershell = Join-Path -Path $PsHome -ChildPath "pwsh"
$AutomountVHDDriveScriptPath = Join-Path $script:TestSourceRoot 'AutomountVHDDrive.ps1'
$vhdPath = Join-Path $TestDrive 'TestAutomountVHD.vhd'
$AutomountSubstDriveScriptPath = Join-Path $script:TestSourceRoot 'AutomountSubstDrive.ps1'
$substDir = Join-Path (Join-Path $TestDrive 'TestAutomountSubstDrive') 'TestDriveRoot'
New-Item $substDir -ItemType Directory -Force | Out-Null
$SubstNotFound = $false
try { subst.exe } catch { $SubstNotFound = $true }
$VHDToolsNotFound = $false
try
{
$tmpVhdPath = Join-Path $TestDrive 'TestVHD.vhd'
New-VHD -path $tmpVhdPath -SizeBytes 5mb -Dynamic -ErrorAction Stop
Remove-Item $tmpVhdPath
}
catch
{ $VHDToolsNotFound = $true }
}
Context "Validating automounting FileSystem drives" {
It "Test automounting using subst.exe" -Skip:$SubstNotFound {
& $powershell -noprofile -command "& '$AutomountSubstDriveScriptPath' -FullPath '$substDir'" | Should Be "Drive found"
}
It "Test automounting using New-VHD/Mount-VHD" -Skip:$VHDToolsNotFound {
& $powershell -noprofile -command "& '$AutomountVHDDriveScriptPath' -VHDPath '$vhdPath'" | Should Be "Drive found"
}
}
Context "Validating automounting FileSystem drives from modules" {
It "Test automounting using subst.exe" -Skip:$SubstNotFound {
& $powershell -noprofile -command "& '$AutomountSubstDriveScriptPath' -useModule -FullPath '$substDir'" | Should Be "Drive found"
}
It "Test automounting using New-VHD/Mount-VHD" -Skip:$VHDToolsNotFound {
$vhdPath = Join-Path $TestDrive 'TestAutomountVHD.vhd'
& $powershell -noprofile -command "& '$AutomountVHDDriveScriptPath' -useModule -VHDPath '$vhdPath'" | Should Be "Drive found"
}
}
}