Skip to content

Commit

Permalink
Refactor package hold verification tests (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak authored Mar 27, 2024
1 parent 440282e commit 794e082
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions molecule/hold/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,31 @@
ansible.builtin.package_facts:

- name: Verify package versions
ansible.builtin.fail:
msg: "Expected installed version for package {{ _package }} to be {{ _version }}, found {{ _installed }}"
ansible.builtin.assert:
that:
- _package in packages
- _version == _installed
fail_msg: "Expected {{ _package }}={{ _version }}, found {{ _package }}={{ _installed }}"
success_msg: "Found {{ _package }}={{ _version }}"
vars:
_package: "{{ item.split('=') | first }}"
_version: "{{ item.split('=') | last }}"
_installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}"
loop: "{{ mongos_package_list }}"
when:
- ansible_os_family == "Debian"
- _package not in packages or _version != _installed
when: ansible_os_family == "Debian"

- name: Verify package versions
ansible.builtin.fail:
msg: "Expected installed version for package {{ _package }} to be {{ _version }}, found {{ _installed }}"
ansible.builtin.assert:
that:
- _package in packages
- _version == _installed
fail_msg: "Expected {{ _package }}={{ _version }}, found {{ _package }}={{ _installed }}"
success_msg: "Found {{ _package }}={{ _version }}"
vars:
_prefix: "^{{ _package }}-"
_suffix: "-.*$"
_package: "{{ item.0 }}"
_version: "{{ item.1 | regex_replace(_prefix, '') | regex_replace(_suffix, '') }}"
_installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}"
loop: "{{ mongos_packages | zip(mongos_package_list) }}"
when:
- ansible_os_family == "RedHat"
- _package not in packages or _version != _installed
when: ansible_os_family == "RedHat"

0 comments on commit 794e082

Please sign in to comment.