mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-15 04:39:12 -07:00
* Add integration tests for snap
* Also test on fedora and remove snapd if it was not installed
* disable test for now
(cherry picked from commit a97d82be88
)
Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
parent
0d0194fdf8
commit
7ef25be10c
2 changed files with 78 additions and 0 deletions
6
tests/integration/targets/snap/aliases
Normal file
6
tests/integration/targets/snap/aliases
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
shippable/posix/group1
|
||||||
|
skip/aix
|
||||||
|
skip/freebsd
|
||||||
|
skip/osx
|
||||||
|
skip/macos
|
||||||
|
disabled #FIXME 2609
|
72
tests/integration/targets/snap/tasks/main.yml
Normal file
72
tests/integration/targets/snap/tasks/main.yml
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
---
|
||||||
|
####################################################################
|
||||||
|
# WARNING: These are designed specifically for Ansible tests #
|
||||||
|
# and should not be used as examples of how to write Ansible roles #
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
- name: install snapd
|
||||||
|
apt:
|
||||||
|
name: snapd
|
||||||
|
state: present
|
||||||
|
register: snapd_install_ubuntu
|
||||||
|
when: ansible_distribution == 'Ubuntu'
|
||||||
|
|
||||||
|
- name: install snapd
|
||||||
|
dnf:
|
||||||
|
name: snapd
|
||||||
|
state: present
|
||||||
|
register: snapd_install_fedora
|
||||||
|
when: ansible_distribution == 'Fedora'
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: install package
|
||||||
|
community.general.snap:
|
||||||
|
name: hello-world
|
||||||
|
state: present
|
||||||
|
register: install
|
||||||
|
|
||||||
|
- name: install package again
|
||||||
|
community.general.snap:
|
||||||
|
name: hello-world
|
||||||
|
state: present
|
||||||
|
register: install_again
|
||||||
|
|
||||||
|
- name: Assert package has been installed just once
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install is changed
|
||||||
|
- install_again is not changed
|
||||||
|
|
||||||
|
- name: check package has been installed correctly
|
||||||
|
command: hello-world
|
||||||
|
|
||||||
|
- name: remove package
|
||||||
|
community.general.snap:
|
||||||
|
name: hello-world
|
||||||
|
state: absent
|
||||||
|
register: remove
|
||||||
|
|
||||||
|
- name: remove package again
|
||||||
|
community.general.snap:
|
||||||
|
name: hello-world
|
||||||
|
state: absent
|
||||||
|
register: remove_again
|
||||||
|
|
||||||
|
- name: Assert package has been removed just once
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- remove is changed
|
||||||
|
- remove_again is not changed
|
||||||
|
when: ansible_distribution in ['Ubuntu','Fedora']
|
||||||
|
|
||||||
|
- name: Remove snapd in case it was not installed
|
||||||
|
apt:
|
||||||
|
name: snapd
|
||||||
|
state: absent
|
||||||
|
when: snapd_install_ubuntu is changed and ansible_distribution == 'Ubuntu'
|
||||||
|
|
||||||
|
- name: Remove snapd in case it was not installed
|
||||||
|
dnf:
|
||||||
|
name: snapd
|
||||||
|
state: absent
|
||||||
|
when: snapd_install_fedora is changed and ansible_distribution == 'Fedora'
|
Loading…
Add table
Add a link
Reference in a new issue