Add intentional tests for dnf group remove (#81739)

* Add intentional tests for dnf group remove

* Copy tests from yum
pull/81858/head
Martin Krizek 1 year ago committed by GitHub
parent b7903669b4
commit 116766ac3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -436,10 +436,6 @@
name: landsidescalping
state: absent
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
- shell: 'dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"'
register: shell_dnf_result
- dnf:
name: "@Custom Group"
state: absent
@ -460,9 +456,6 @@
- dnf_result is changed
- "'results' in dnf_result"
# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
- shell: dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"
- dnf:
name: "@Custom Group"
state: absent

@ -0,0 +1,141 @@
- name: install a group to test and dnf-utils
dnf:
name: "{{ pkgs }}"
state: present
vars:
pkgs:
- "@Custom Group"
- dnf-utils
- name: check mode remove the group
dnf:
name: "@Custom Group"
state: absent
check_mode: yes
register: dnf_result
- name: verify changed
assert:
that:
- "dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'results' in dnf_result"
- name: remove the group
dnf:
name: "@Custom Group"
state: absent
register: dnf_result
- name: verify changed
assert:
that:
- "dnf_result.rc == 0"
- "dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'msg' in dnf_result"
- "'results' in dnf_result"
- name: remove the group again
dnf:
name: "@Custom Group"
state: absent
register: dnf_result
- name: verify changed
assert:
that:
- "not dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'msg' in dnf_result"
- "'results' in dnf_result"
- name: check mode remove the group again
dnf:
name: "@Custom Group"
state: absent
check_mode: yes
register: dnf_result
- name: verify changed
assert:
that:
- "not dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'results' in dnf_result"
- name: install a group and a package to test
dnf:
name: "@Custom Group,sos"
state: present
register: dnf_output
- name: check mode remove the group along with the package
dnf:
name: "@Custom Group,sos"
state: absent
register: dnf_result
check_mode: yes
- name: verify changed
assert:
that:
- "dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'results' in dnf_result"
- name: remove the group along with the package
dnf:
name: "@Custom Group,sos"
state: absent
register: dnf_result
- name: verify changed
assert:
that:
- "dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'msg' in dnf_result"
- "'results' in dnf_result"
- name: check mode remove the group along with the package
dnf:
name: "@Custom Group,sos"
state: absent
register: dnf_result
check_mode: yes
- name: verify not changed
assert:
that:
- "not dnf_result.changed"
- name: verify dnf module outputs
assert:
that:
- "'changed' in dnf_result"
- "'results' in dnf_result"

@ -47,6 +47,13 @@
when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
(ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
- include_tasks: dnf_group_remove.yml
when:
- (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
(ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
# https://github.com/rpm-software-management/dnf5/issues/917
- not dnf5|default(false)
- include_tasks: dnfinstallroot.yml
when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
(ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))

Loading…
Cancel
Save