8000 Add new test · PowerShell/PowerShell@1bc1de8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1bc1de8

Browse files
committed
Add new test
1 parent 39d1e94 commit 1bc1de8

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

test/powershell/Modules/Microsoft.PowerShell.Management/Remove-Item.Tests.ps1

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Describe "Remove-Item" -Tags "CI" {
126126
}
127127

128128
It "Should be able to remove a directory" {
129-
{ Remove-Item $testdirectory } | Should -Not -Throw
129+
{ Remove-Item $testdirectory -ErrorAction Stop } | Should -Not -Throw
130130

131131
Test-Path $testdirectory | Should -BeFalse
132132
}
@@ -138,16 +138,32 @@ Describe "Remove-Item" -Tags "CI" {
138138
$complexDirectory = Join-Path -Path $testsubdirectory -ChildPath $testfile
139139
Test-Path $complexDirectory | Should -BeTrue
140140

141-
{ Remove-Item $testdirectory -Recurse } | Should -Not -Throw
141+
{ Remove-Item $testdirectory -Recurse -ErrorAction Stop } | Should -Not -Throw
142142

143143
Test-Path $testdirectory | Should -BeFalse
144144
}
145+
146+
It "Should be able to recursively delete a directory with a trailing backslash" {
147+
New-Item -Name "subd" -Path $testdirectory -ItemType "directory"
148+
New-Item -Name $testfile -Path $testsubdirectory -ItemType "file" -Value "lorem ipsum"
149+
150+
$complexDirectory = Join-Path -Path $testsubdirectory -ChildPath $testfile
151+
Test-Path $complexDirectory | Should -BeTrue
152+
153+
$testdirectoryWithBackSlash = Join-Path -Path $testdirectory -ChildPath ([IO.Path]::DirectorySeparatorChar)
154+
Test-Path $testdirectoryWithBackSlash | Should -BeTrue
155+
156+
{ Remove-Item $testdirectoryWithBackSlash -Recurse -ErrorAction Stop } | Should -Not -Throw
157+
158+
Test-Path $testdirectoryWithBackSlash | Should -BeFalse
159+
Test-Path $testdirectory | Should -BeFalse
160+
}
145161
}
146162

147163
Context "Alternate Data Streams should be supported on Windows" {
148164
BeforeAll {
149165
if (!$IsWindows) {
150-
return
166+
return
151167
}
152168
$fileName = "ADStest.txt"
153169
$streamName = "teststream"

0 commit comments

Comments
 (0)
0