@@ -621,6 +621,27 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
621
621
$ps.Dispose ()
622
622
}
623
623
}
624
+
625
+ It " Validate that Compress-Archive returns nothing when -PassThru is not used" {
626
+ $sourcePath = @ (" $TestDrive \SourceDir" )
627
+ $destinationPath = " $TestDrive \NoPassThruTest.zip"
628
+ $archive = Compress-Archive - Path $sourcePath - DestinationPath $destinationPath
629
+ $archive | Should Be $null
630
+ }
631
+
632
+ It " Validate that Compress-Archive returns nothing when -PassThru is used with a value of $false " {
633
+ $sourcePath = @ (" $TestDrive \SourceDir" )
634
+ $destinationPath = " $TestDrive \FalsePassThruTest.zip"
635
+ $archive = Compress-Archive - Path $sourcePath - DestinationPath $destinationPath - PassThru:$false
636
+ $archive | Should Be $null
637
+ }
638
+
639
+ It " Validate that Compress-Archive returns the archive when invoked with -PassThru" {
640
+ $sourcePath = @ (" $TestDrive \SourceDir" )
641
+ $destinationPath = " $TestDrive \PassThruTest.zip"
642
+ $archive = Compress-Archive - Path $sourcePath - DestinationPath $destinationPath - PassThru
643
+ $archive.FullName | Should Be $destinationPath
644
+ }
624
645
}
625
646
626
647
Context " Expand-Archive - Parameter validation test cases" {
@@ -947,5 +968,50 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "BVT" {
947
968
Pop-Location
948
969
}
949
970
}
971
+
972
+ It " Validate that Expand-Archive returns nothing when -PassThru is not used" {
973
+ $sourcePath = " $TestDrive \SourceDir"
974
+ $archivePath = " $TestDrive \NoPassThruTestForExpand.zip"
975
+ $destinationPath = " $TestDrive \NoPassThruTest"
976
+ $sourceList = dir $sourcePath - Name
977
+
978
+ Add-CompressionAssemblies
979
+ [System.IO.Compression.ZipFile ]::CreateFromDirectory($sourcePath , $archivePath )
980
+
981
+ $contents = Expand-Archive - Path $archivePath - DestinationPath $destinationPath
982
+
983
+ $contents | Should Be $null
984
+ }
985
+
986
+ It " Validate that Expand-Archive returns nothing when -PassThru is used with a value of $false " {
987
+ $sourcePath = " $TestDrive \SourceDir"
988
+ $archivePath = " $TestDrive \FalsePassThruTestForExpand.zip"
989
+ $destinationPath = " $TestDrive \FalsePassThruTest"
990
+ $sourceList = dir $sourcePath - Name
991
+
992
+ Add-CompressionAssemblies
993
+ [System.IO.Compression.ZipFile ]::CreateFromDirectory($sourcePath , $archivePath )
994
+
995
+ $contents = Expand-Archive - Path $archivePath - DestinationPath $destinationPath - PassThru:$false
996
+
997
+ $contents | Should Be $null
998
+ }
999
+
1000
+ It " Validate that Expand-Archive returns the contents of the archive -PassThru" {
1001
+ $sourcePath = " $TestDrive \SourceDir"
1002
+ $archivePath = " $TestDrive \PassThruTestForExpand.zip"
1003
+ $destinationPath = " $TestDrive \PassThruTest"
1004
+ $sourceList = dir $sourcePath - Name
1005
+
1006
+ Add-CompressionAssemblies
1007
+ [System.IO.Compression.ZipFile ]::CreateFromDirectory($sourcePath , $archivePath )
1008
+
1009
+ $contents = Expand-Archive - Path $archivePath - DestinationPath $destinationPath - PassThru | Sort-Object - Property PSParentPath, PSIsDirectory, Name
1010
+ # We pipe Get-ChildItem to Get-Item here because the ToString results are different between the two, and we
1011
+ # need to compare with other Get-Item results
1012
+ $extractedList = Get-ChildItem - Recurse - LiteralPath $destinationPath | Get-Item
1013
+
1014
+ Compare-Object - ReferenceObject $extractedList - DifferenceObject $contents - PassThru | Should Be $null
1015
+ }
950
1016
}
951
1017
}
0 commit comments