@@ -261,11 +261,16 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
261
261
$path = @ (" $TestDrive " , " HKLM:\SOFTWARE" )
262
262
CompressArchiveInValidPathValidator $path $TestDrive " HKLM:\SOFTWARE" " PathNotFound,Compress-Archive"
263
263
264
- $invalidUnZipFileFormat = " $TestDrive \Sample.unzip"
265
- CompressArchiveInValidArchiveFileExtensionValidator $TestDrive " $invalidUnZipFileFormat " " .unzip"
264
+ # The tests below are no longer valid. You can have zip files with non-zip extensions. Different archive
265
+ # formats should be added in a separate pull request, with a parameter to identify the archive format, and
266
+ # default formats associated with specific extensions. Until then, as long as these cmdlets only support
267
+ # Zip files, any file extension is supported.
268
+
269
+ # $invalidUnZipFileFormat = "$TestDrive\Sample.unzip"
270
+ # CompressArchiveInValidArchiveFileExtensionValidator $TestDrive "$invalidUnZipFileFormat" ".unzip"
266
271
267
- $invalidcabZipFileFormat = " $TestDrive \Sample.cab"
268
- CompressArchiveInValidArchiveFileExtensionValidator $TestDrive " $invalidcabZipFileFormat " " .cab"
272
+ # $invalidcabZipFileFormat = "$TestDrive\Sample.cab"
273
+ # CompressArchiveInValidArchiveFileExtensionValidator $TestDrive "$invalidcabZipFileFormat" ".cab"
269
274
}
270
275
271
276
It " Validate error from Compress-Archive when archive file already exists and -Update parameter is not specified" {
@@ -642,6 +647,13 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
642
647
$archive = Compress-Archive - Path $sourcePath - DestinationPath $destinationPath - PassThru
643
648
$archive.FullName | Should Be $destinationPath
644
649
}
650
+
651
+ It " Validate that Compress-Archive can create a zip archive that has a different extension" {
652
+ $sourcePath = " $TestDrive \SourceDir\ChildDir-1\Sample-3.txt"
653
+ $destinationPath = " $TestDrive \DifferentZipExtension.dat"
654
+ Compress-Archive - Path $sourcePath - DestinationPath $destinationPath
655
+ $destinationPath | Should Exist
656
+ }
645
657
}
646
658
647
659
Context " Expand-Archive - Parameter validation test cases" {
@@ -854,19 +866,23 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
854
866
}
855
867
}
856
868
857
- It " Invoke Expand-Archive with unsupported archive format" {
858
- $sourcePath = " $TestDrive \Sample.cab"
859
- $destinationPath = " $TestDrive \UnsupportedArchiveFormatDir"
860
- try
861
- {
862
- Expand-Archive - Path $sourcePath - DestinationPath $destinationPath - Force
863
- throw " Failed to detect unsupported archive format at $sourcePath "
864
- }
865
- catch
866
- {
867
- $_.FullyQualifiedErrorId | Should Be " NotSupportedArchiveFileExtension,Expand-Archive"
868
- }
869
- }
869
+ # The test below is no longer valid. You can have zip files with non-zip extensions. Different archive
870
+ # formats should be added in a separate pull request, with a parameter to identify the archive format, and
871
+ # default formats associated with specific extensions. Until then, as long as these cmdlets only support
872
+ # Zip files, any file extension is supported.
873
+ # It "Invoke Expand-Archive with unsupported archive format" {
874
+ # $sourcePath = "$TestDrive\Sample.cab"
875
+ # $destinationPath = "$TestDrive\UnsupportedArchiveFormatDir"
876
+ # try
877
+ # {
878
+ # Expand-Archive -Path $sourcePath -DestinationPath $destinationPath -Force
879
+ # throw "Failed to detect unsupported archive format at $sourcePath"
880
+ # }
881
+ # catch
882
+ # {
883
+ # $_.FullyQualifiedErrorId | Should Be "NotSupportedArchiveFileExtension,Expand-Archive"
884
+ # }
885
+ # }
870
886
871
887
It " Invoke Expand-Archive with archive file containing multiple files, directories with subdirectories and empty directories" {
872
888
$sourcePath = " $TestDrive \SourceDir"
@@ -986,6 +1002,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
986
1002
$sourcePath = " $TestDrive \SourceDir"
987
1003
$archivePath = " $TestDrive \NoPassThruTestForExpand.zip"
988
1004
$destinationPath = " $TestDrive \NoPassThruTest"
1005
+
989
1006
$sourceList = dir $sourcePath - Name
990
1007
991
1008
Add-CompressionAssemblies
@@ -1026,5 +1043,20 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
1026
1043
1027
1044
Compare-Object - ReferenceObject $extractedList - DifferenceObject $contents - PassThru | Should Be $null
1028
1045
}
1046
+
1047
+ It " Validate Expand-Archive works with zip files that have non-zip file extensions" {
1048
+ $sourcePath = " $TestDrive \SourceDir"
1049
+ $archivePath = " $TestDrive \NonZipFileExtension.dat"
1050
+ $destinationPath = " $TestDrive \NonZipFileExtension"
1051
+ $sourceList = dir $sourcePath - Name
1052
+
1053
+ Add-CompressionAssemblies
1054
+ [System.IO.Compression.ZipFile ]::CreateFromDirectory($sourcePath , $archivePath )
1055
+
1056
+ Expand-Archive - Path $archivePath - DestinationPath $destinationPath
1057
+ $extractedList = dir $destinationPath - Name
1058
+
1059
+ Compare-Object - ReferenceObject $extractedList - DifferenceObject $sourceList - PassThru | Should Be $null
1060
+ }
1029
1061
}
1030
1062
}
0 commit comments