-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add negative tests for Copy-Item over remote sessions #6231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
f183099
59073b1
699a5b9
5d3a592
ef506b4
5f93512
829bcd9
c29c33d
1862205
9a0bb
8000
ac
1bf5824
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,6 +483,28 @@ 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." { | ||
$s1 = New-PSSession -ComputerName . -ea SilentlyContinue | ||
if (-not $s1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer a Pester check. $s1 | Should Not BeNullOrEmpty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put the test in a |
||
{ | ||
throw "Failed to create PSSession for remote copy operations." | ||
} | ||
$filePath = CreateTestFile | ||
$destinationFolderPath = GetDestinationFolderPath | ||
{ Copy-Item -Path $filePath -Destination $destinationFolderPath -FromSession $s -ToSession $s1 -ErrorAction Stop } | ShouldBeErrorId "InvalidInput,Microsoft.PowerShell.Commands.CopyItemCommand" | ||
} | ||
} | ||
|
||
Context "Validate Copy-Item Remotely using wildcards" { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1401,3 +1401,4 @@ Describe "UNC paths" -Tags 'CI' { | |
} | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the extra line here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-ErrorAction
instead of-ea