1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add integration tests for snap (#2907)

* Add integration tests for snap

* Also test on fedora and remove snapd if it was not installed

* disable test for now
This commit is contained in:
Amin Vakil 2021-06-30 17:36:56 +04:30 committed by GitHub
parent 0e829e6a23
commit a97d82be88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,6 @@
shippable/posix/group1
skip/aix
skip/freebsd
skip/osx
skip/macos
disabled #FIXME 2609

View 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'