- 'throw_module.msg == "Unhandled exception while executing module: module is thrown"'
- '"throw [ArgumentException]\"module is thrown\"" in throw_module.exception'
- name:test module with error msg
test_fail:
data:error
register:error_module
ignore_errors:yes
- name:assert test module with error msg
assert:
that:
- error_module is failed
- 'error_module.msg == "Unhandled exception while executing module: error"'
- '"Write-Error -Message $data" in error_module.exception'
- name:test module with cmdlet error
test_fail:
data:cmdlet_error
register:cmdlet_error
ignore_errors:yes
- name:assert test module with cmdlet error
assert:
that:
- cmdlet_error is failed
- 'cmdlet_error.msg == "Unhandled exception while executing module: Cannot find drive. A drive with the name ''fake'' does not exist."'
- '"Get-Item -Path \"fake:\\path\"" in cmdlet_error.exception'
- name:test module with .NET exception
test_fail:
data:dotnet_exception
register:dotnet_exception
ignore_errors:yes
- name:assert test module with .NET exception
assert:
that:
- dotnet_exception is failed
- 'dotnet_exception.msg == "Unhandled exception while executing module: Exception calling \"GetFullPath\" with \"1\" argument(s): \"The path is not of a legal form.\""'
- '"[System.IO.Path]::GetFullPath($null)" in dotnet_exception.exception'
- name:test module with function exception
test_fail:
data:function_throw
register:function_exception
ignore_errors:yes
- name:assert test module with function exception
assert:
that:
- function_exception is failed
- 'function_exception.msg == "Unhandled exception while executing module: exception in function"'
- '"throw \"exception in function\"" in function_exception.exception'
- '"at Test-ThrowException, <No file>: line" in function_exception.exception'
- name:test module with fail process but Exit-Json
test_fail:
data:proc_exit_fine
register:proc_exit_fine
- name:assert test module with fail process but Exit-Json
assert:
that:
- not proc_exit_fine is failed
- name:test module with fail process but Fail-Json
test_fail:
data:proc_exit_fail
register:proc_exit_fail
ignore_errors:yes
- name:assert test module with fail process but Fail-Json