win_shortcut: Add missing $check_mode definition + bugfix + tests (#20911)

* win_shortcut: Add missing $check_mode definition

For some reason this entry was missing, possible a merge-conflict gone
wrong :-(

* Added integration tests and bugfix

Add missing changes.
This commit is contained in:
Dag Wieers 2017-02-02 10:29:56 +01:00 committed by John R Barker
commit 3dbce15ccb
4 changed files with 167 additions and 0 deletions

View file

@ -24,6 +24,7 @@
$ErrorActionPreference = "Stop"
$params = Parse-Args $args -supports_check_mode $true
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
$src = Get-AnsibleParam -obj $params -name "src" -type "path" -default $null
$dest = Get-AnsibleParam -obj $params -name "dest" -type "path" -failifempty $true
@ -78,6 +79,13 @@ If ($state -eq "absent") {
# Compare existing values with new values, report as changed if required
If ($src -ne $null) {
# Windows translates executables to absolute path, so do we
If (Get-Command -Name $src -Type Application -ErrorAction SilentlyContinue) {
$src = (Get-Command -Name $src -Type Application).Definition
}
}
If ($src -ne $null -and $ShortCut.TargetPath -ne $src) {
$result.changed = $true
$ShortCut.TargetPath = $src