mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-24 04:54:00 -07:00
fix Ansible.ModuleUtils.FileUtil to respect ErrorAction if running in a try/catch (#45451)
This commit is contained in:
parent
c9c141fb6a
commit
d4ce1b9f31
2 changed files with 18 additions and 1 deletions
|
|
@ -96,5 +96,13 @@ Assert-Equals -actual $actual.FullName -expected C:\Windows
|
|||
Assert-Equals -actual $actual.Attributes.HasFlag([System.IO.FileAttributes]::Directory) -expected $true
|
||||
Assert-Equals -actual $actual.Exists -expected $true
|
||||
|
||||
# ensure Get-AnsibleItem doesn't fail in a try/catch and -ErrorAction SilentlyContinue - stop's a trap from trapping it
|
||||
try {
|
||||
$actual = Get-AnsibleItem -Path C:\fakepath -ErrorAction SilentlyContinue
|
||||
} catch {
|
||||
Fail-Json -obj $result -message "this should not fire"
|
||||
}
|
||||
Assert-Equals -actual $actual -expected $null
|
||||
|
||||
$result.data = "success"
|
||||
Exit-Json -obj $result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue