mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Implement integration tests for apk (#7992)
* Implement integration tests for apk * Add group for apk integration test * Adjust integration tests of apk as suggested in PR
This commit is contained in:
parent
551b0b9eea
commit
ffa3d15881
2 changed files with 173 additions and 0 deletions
13
tests/integration/targets/apk/aliases
Normal file
13
tests/integration/targets/apk/aliases
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
azp/posix/2
|
||||||
|
needs/root
|
||||||
|
destructive
|
||||||
|
skip/aix
|
||||||
|
skip/osx
|
||||||
|
skip/macos
|
||||||
|
skip/freebsd
|
||||||
|
skip/rhel
|
||||||
|
skip/ubuntu
|
160
tests/integration/targets/apk/tasks/main.yml
Normal file
160
tests/integration/targets/apk/tasks/main.yml
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
####################################################################
|
||||||
|
# WARNING: These are designed specifically for Ansible tests #
|
||||||
|
# and should not be used as examples of how to write Ansible roles #
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
# Copyright (c) 2024, Max Maxopoly <max@dermax.org>
|
||||||
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
- name: Run apk tests on Alpine
|
||||||
|
when: ansible_distribution in ['Alpine']
|
||||||
|
block:
|
||||||
|
- name: Ensure vim is not installed
|
||||||
|
community.general.apk:
|
||||||
|
name: vim
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Install vim
|
||||||
|
community.general.apk:
|
||||||
|
name: vim
|
||||||
|
state: present
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure vim was installed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is changed
|
||||||
|
- (results.packages | length) >= 1 # vim has dependencies, so depending on the base image this number may vary
|
||||||
|
|
||||||
|
- name: Install vim again
|
||||||
|
community.general.apk:
|
||||||
|
name: vim
|
||||||
|
state: present
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure vim was not installed again
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is not changed
|
||||||
|
- (results.packages | default([]) | length) == 0
|
||||||
|
|
||||||
|
- name: Ensure vim is not installed
|
||||||
|
community.general.apk:
|
||||||
|
name: vim
|
||||||
|
state: absent
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure vim was uninstalled
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is changed
|
||||||
|
- (results.packages | length) >= 1
|
||||||
|
|
||||||
|
- name: Install vim without cache
|
||||||
|
community.general.apk:
|
||||||
|
name: vim
|
||||||
|
state: present
|
||||||
|
no_cache: true
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure vim was installed without cache
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is changed
|
||||||
|
|
||||||
|
- name: Install vim again without cache
|
||||||
|
community.general.apk:
|
||||||
|
name: vim
|
||||||
|
state: present
|
||||||
|
no_cache: true
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure vim was not installed again without cache
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is not changed
|
||||||
|
- (results.packages | default([]) | length) == 0
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages aren't installed
|
||||||
|
community.general.apk:
|
||||||
|
name:
|
||||||
|
- less
|
||||||
|
- nano
|
||||||
|
- vim
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Install a bunch of packages
|
||||||
|
community.general.apk:
|
||||||
|
name:
|
||||||
|
- less
|
||||||
|
- nano
|
||||||
|
- vim
|
||||||
|
state: present
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages were installed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is changed
|
||||||
|
- (results.packages | length) >= 3
|
||||||
|
|
||||||
|
- name: Install a bunch of packages again
|
||||||
|
community.general.apk:
|
||||||
|
name:
|
||||||
|
- less
|
||||||
|
- nano
|
||||||
|
- vim
|
||||||
|
state: present
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages were not installed again
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is not changed
|
||||||
|
- (results.packages | default([]) | length) == 0
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages are not installed
|
||||||
|
community.general.apk:
|
||||||
|
name:
|
||||||
|
- less
|
||||||
|
- nano
|
||||||
|
- vim
|
||||||
|
state: absent
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages were uninstalled
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is changed
|
||||||
|
- (results.packages | length) >= 3
|
||||||
|
|
||||||
|
- name: Install a bunch of packages without cache
|
||||||
|
community.general.apk:
|
||||||
|
name:
|
||||||
|
- less
|
||||||
|
- nano
|
||||||
|
- vim
|
||||||
|
state: present
|
||||||
|
no_cache: true
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages were installed without cache
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is changed
|
||||||
|
|
||||||
|
- name: Install a bunch of packages again without cache
|
||||||
|
community.general.apk:
|
||||||
|
name:
|
||||||
|
- less
|
||||||
|
- nano
|
||||||
|
- vim
|
||||||
|
state: present
|
||||||
|
no_cache: true
|
||||||
|
register: results
|
||||||
|
|
||||||
|
- name: Ensure a bunch of packages were not installed again without cache
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- results is not changed
|
||||||
|
- (results.packages | default([]) | length) == 0
|
Loading…
Reference in a new issue