mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
apt_repository: check attribute repo for None value (#36944)
This commit is contained in:
parent
5be9315603
commit
26d9de6f3e
2 changed files with 25 additions and 0 deletions
|
@ -503,6 +503,9 @@ def main():
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg='%s is not installed, and install_python_apt is False' % PYTHON_APT)
|
module.fail_json(msg='%s is not installed, and install_python_apt is False' % PYTHON_APT)
|
||||||
|
|
||||||
|
if not repo:
|
||||||
|
module.fail_json(msg='Please set argument \'repo\' to a non-empty value')
|
||||||
|
|
||||||
if isinstance(distro, aptsources_distro.Distribution):
|
if isinstance(distro, aptsources_distro.Distribution):
|
||||||
sourceslist = UbuntuSourcesList(module, add_ppa_signing_keys_callback=get_add_ppa_signing_key_callback(module))
|
sourceslist = UbuntuSourcesList(module, add_ppa_signing_keys_callback=get_add_ppa_signing_key_callback(module))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -199,6 +199,28 @@
|
||||||
- name: 'ensure ppa key is absent (expect: pass)'
|
- name: 'ensure ppa key is absent (expect: pass)'
|
||||||
apt_key: id='{{test_ppa_key}}' state=absent
|
apt_key: id='{{test_ppa_key}}' state=absent
|
||||||
|
|
||||||
|
- name: Test apt_repository with a null value for repo
|
||||||
|
apt_repository:
|
||||||
|
repo:
|
||||||
|
register: result
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is failed
|
||||||
|
- result.msg == 'Please set argument \'repo\' to a non-empty value'
|
||||||
|
|
||||||
|
- name: Test apt_repository with an empty value for repo
|
||||||
|
apt_repository:
|
||||||
|
repo: ""
|
||||||
|
register: result
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is failed
|
||||||
|
- result.msg == 'Please set argument \'repo\' to a non-empty value'
|
||||||
|
|
||||||
#
|
#
|
||||||
# TEARDOWN
|
# TEARDOWN
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue