ansible/test/integration/targets/win_package/tasks/failure_tests.yml
Jordan Borean f21e72d55a
win_package - Use newer module wrapper as refactor baseline (#65586)
* win_package - Use newer module wrapper as refactor baseline

* Fix aliases in new arg spec
2019-12-06 13:37:52 +10:00

82 lines
3.4 KiB
YAML

# these tests are invalid arguments and failure states for win_package
---
- name: fail to install broken msi
win_package:
path: '{{test_win_package_path}}\bad.msi'
state: present
register: fail_bad_rc
failed_when: "'unexpected rc from install' not in fail_bad_rc.msg and fail_bad_rc.exit_code != 1603"
- name: fail when not using an int for a return code
win_package:
path: '{{test_win_package_path}}\good.msi'
state: present
expected_return_code: 0,abc
register: fail_invalid_return_code
failed_when: "'argument for list entry expected_return_code is of type System>String and we were unable to convert to in' in fail_invalid_return_code.msg"
- name: fail when path is not set and state!= absent
win_package:
state: present
register: fail_no_path
failed_when: 'fail_no_path.msg != "state is present but all of the following are missing: path"'
- name: fail when path is not set and state=absent but product_id is null
win_package:
state: absent
register: fail_no_path_state_absent_no_id
failed_when: 'fail_no_path_state_absent_no_id.msg != "state is absent but any of the following are missing: path, product_id"'
- name: fail when product_id is not set and path is not a local MSI
win_package:
path: '{{test_win_package_good_url}}'
state: present
register: fail_install_url_no_id
failed_when: fail_install_url_no_id.msg != 'product_id is required when the path is not an MSI or the path is an MSI but not local'
- name: fail invalid local path
win_package:
path: '{{test_win_package_path}}\no file.msi'
state: present
register: fail_invalid_local_path
failed_when: fail_invalid_local_path.msg != 'the file at the local path ' + test_win_package_path + '\\no file.msi cannot be reached'
- name: fail invalid URL
win_package:
path: http://fakeurl/file.msi
product_id: 'id'
state: present
register: fail_invalid_url_path
failed_when: "fail_invalid_url_path.msg != 'the file at the URL http://fakeurl/file.msi cannot be reached: The remote name could not be resolved: \\'fakeurl\\''"
- name: fail invalid UNC path
win_package:
path: \\fakenetwork\unc file.msi
product_id: 'id'
state: present
register: fail_invalid_unc_path
failed_when: fail_invalid_unc_path.msg != 'the file at the UNC path \\\\fakenetwork\\unc file.msi cannot be reached, ensure the user_name account has access to this path or use an auth transport with credential delegation'
- name: fail when product_id is not set and path is not a local MSI
win_package:
path: '{{test_win_package_good_url}}'
state: present
register: fail_no_id_not_local_msi
failed_when: fail_no_id_not_local_msi.msg != 'product_id is required when the path is not an MSI or the path is an MSI but not local'
- name: fail to check version without creates_path
win_package:
path: '{{test_win_package_path}}\7z.exe'
state: present
creates_version: 1
register: fail_creates_version_without_path
failed_when: "fail_creates_version_without_path.msg != \"missing parameter(s) required by 'creates_version': creates_path\""
- name: fail to check version without when path is not a file
win_package:
path: '{{test_win_package_path}}\7z.exe'
state: present
creates_path: C:\Windows
creates_version: 1
register: fail_creates_version_not_a_file
failed_when: fail_creates_version_not_a_file.msg != 'creates_path must be a file not a directory when creates_version is set'