mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add negative tests for Copy-Item over remote sessions (#6231)
This commit is contained in:
committed by
Dongbo Wang
parent
06b0bb2eb2
commit
31cef2afb5
@@ -483,6 +483,32 @@ Describe "Validate Copy-Item Remotely" -Tags "CI" {
|
||||
Copy-Item -Path $filePath -FromSession $s -Destination $destinationFolderPath
|
||||
ValidateCopyItemOperationForAlternateDataStream -filePath $filePath -streamName $streamName -expectedStreamContent $streamContent
|
||||
}
|
||||
|
||||
It "Copy file to the same directory fails." {
|
||||
$filePath = CreateTestFile
|
||||
{ Copy-Item -Path $filePath -Destination $sourceDirectory -FromSession $s -ErrorAction Stop } | ShouldBeErrorId "System.IO.IOException,WriteException"
|
||||
}
|
||||
|
||||
It "Copy directory with a -Destination parameter given as a file path fails." {
|
||||
$filePath = CreateTestFile
|
||||
$folderToCopy = GetDestinationFolderPath
|
||||
{ Copy-Item -Path $folderToCopy -Destination $filePath -FromSession $s -ErrorAction Stop } | ShouldBeErrorId "CopyError,Microsoft.PowerShell.Commands.CopyItemCommand"
|
||||
}
|
||||
|
||||
It "Copy-Item parameters -FromSession and -ToSession are mutually exclusive." {
|
||||
try
|
||||
{
|
||||
$s1 = New-PSSession -ComputerName . -ErrorAction SilentlyContinue
|
||||
$s1 | Should Not BeNullOrEmpty
|
||||
$filePath = CreateTestFile
|
||||
$destinationFolderPath = GetDestinationFolderPath
|
||||
{ Copy-Item -Path $filePath -Destination $destinationFolderPath -FromSession $s -ToSession $s1 -ErrorAction Stop } | ShouldBeErrorId "InvalidInput,Microsoft.PowerShell.Commands.CopyItemCommand"
|
||||
}
|
||||
finally
|
||||
{
|
||||
Remove-PSSession -Session $s1 -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "Validate Copy-Item Remotely using wildcards" {
|
||||
|
||||
Reference in New Issue
Block a user