Ignore Remove-Item errors in Split-Path setup

This commit is contained in:
Andrew Schwartzmeyer 2015-08-28 20:13:10 -07:00
parent 7b1280eb2e
commit 92cd86d3f2

View file

@ -14,27 +14,29 @@
# ErrorAction SilentlyContinue merely suppresses the error from the console.
# Throwing exceptions still seen by Pester.
Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw
Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw
}
It "Should error when no directory separator characters are used with a qualifier" {
Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw
Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw
}
It "Should return the path when the noqualifier switch is used on a linux system" {
It "Should return the path when the noqualifier switch is used on a Linux system" {
{ Split-Path /usr/bin -NoQualifier } | Should Not Throw
Split-Path /usr/bin -NoQualifier | Should Be "/usr/bin"
}
It "Should return the parent folder name when the leaf switch is used" {
It "Should return the base name when the leaf switch is used" {
Split-Path /usr/bin -Leaf | Should be "bin"
Split-Path /usr/local/bin -Leaf | Should be "bin"
Split-Path usr/bin -Leaf | Should be "bin"
Split-Path ./bin -Leaf | Should be "bin"
Split-Path bin -Leaf | Should be "bin"
}
It "Should be able to accept regular expression input and output an array for multiple objects" {
$testDir = "./tmp"
Remove-Item $testDir -Recurse -Force
Remove-Item $testDir -Recurse -Force -ErrorAction Ignore
$testFile1 = "testfile1.ps1"
$testFile2 = "testfile2.ps1"
@ -51,7 +53,7 @@
$actual[0] | Should Be $testFile1
$actual[1] | Should Be $testFile2
Remove-Item $testDir -Recurse -Force
Remove-Item $testDir -Recurse -Force -ErrorAction Ignore
Test-Path $testDir | Should Be $false
}