Skip to content

Commit d5c42b4

Browse files
author
Andrew
committed
replaced forward/backslash tests with a mixed-slash test
1 parent 3ea69c0 commit d5c42b4

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

Tests/Pester.Commands.Cmdlets.Archive.Tests.ps1

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -654,20 +654,6 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
654654
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
655655
$destinationPath | Should Exist
656656
}
657-
658-
It "Validate that Compress-Archive cmdlet works with backslashes in paths" {
659-
$sourcePath = "$TestDrive\SourceDir\ChildDir-1"
660-
$destinationPath = "$TestDrive\SampleBackslashFile.zip"
661-
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
662-
$destinationPath | Should Exist
663-
}
664-
665-
It "Validate that Compress-Archive cmdlet works with forward slashes in paths" {
666-
$sourcePath = "$TestDrive/SourceDir/ChildDir-1"
667-
$destinationPath = "$TestDrive/SampleForwardslashFile.zip"
668-
Compress-Archive -Path $sourcePath -DestinationPath $destinationPath
669-
$destinationPath | Should Exist
670-
}
671657
}
672658

673659
Context "Expand-Archive - Parameter validation test cases" {
@@ -1084,31 +1070,21 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
10841070
}
10851071
}
10861072

1087-
It "Validate that Expand-Archive cmdlet works with backslashes in paths" {
1088-
$sourcePath = "$TestDrive\SamplePreCreatedArchive.zip"
1089-
$content = "Some Data"
1090-
$destinationPath = "$TestDrive\DestDirForBackslashExpand"
1091-
$files = @("Sample-1.txt", "Sample-2.txt")
1092-
1093-
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
1094-
foreach($currentFile in $files)
1095-
{
1096-
$expandedFile = Join-Path $destinationPath -ChildPath $currentFile
1097-
Test-Path $expandedFile | Should Be $True
1098-
Get-Content $expandedFile | Should Be $content
1099-
}
1100-
}
1073+
It "Validate that Compress-Archive/Expand-Archive work with backslashes and forward slashes in paths" {
1074+
$sourcePath = "$TestDrive\SourceDir/ChildDir-2"
1075+
$archivePath = "$TestDrive\MixedSlashesDir1/MixedSlashesDir2/SampleMixedslashFile.zip"
1076+
$expandPath = "$TestDrive\MixedSlashesExpandDir/DirA\DirB/DirC"
11011077

1102-
It "Validate that Expand-Archive cmdlet works with forward slashes in paths" {
1103-
$sourcePath = "$TestDrive/SamplePreCreatedArchive.zip"
1078+
New-Item -Path (Split-Path $archivePath) -Type Directory | Out-Null
1079+
Compress-Archive -Path $sourcePath -DestinationPath $archivePath
1080+
$archivePath | Should Exist
1081+
11041082
$content = "Some Data"
1105-
$destinationPath = "$TestDrive/DestDirForForwardslashExpand"
1106-
$files = @("Sample-1.txt", "Sample-2.txt")
1107-
1108-
Expand-Archive -Path $sourcePath -DestinationPath $destinationPath
1083+
$files = @("ChildDir-2$($DS)Sample-5.txt", "ChildDir-2$($DS)Sample-6.txt")
1084+
Expand-Archive -Path $archivePath -DestinationPath $expandPath
11091085
foreach($currentFile in $files)
11101086
{
1111-
$expandedFile = Join-Path $destinationPath -ChildPath $currentFile
1087+
$expandedFile = Join-Path $expandPath -ChildPath $currentFile
11121088
Test-Path $expandedFile | Should Be $True
11131089
Get-Content $expandedFile | Should Be $content
11141090
}

0 commit comments

Comments
 (0)