mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-03 23:41:51 +00:00
97 lines
2.4 KiB
YAML
97 lines
2.4 KiB
YAML
---
|
|
####################################################################
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
####################################################################
|
|
|
|
# Test code for the archive module.
|
|
# Copyright (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
|
# 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
|
|
|
|
# Make sure we start fresh
|
|
|
|
# Test setup
|
|
- name: prep our files
|
|
copy: src={{ item }} dest={{remote_tmp_dir}}/{{ item }}
|
|
with_items:
|
|
- foo.txt
|
|
- bar.txt
|
|
- empty.txt
|
|
- sub
|
|
- sub/subfile.txt
|
|
|
|
# Run twice without lzma backport installed, to make sure it does not crash
|
|
- name: Archive - pre-test - first run
|
|
archive:
|
|
path: "{{ remote_tmp_dir }}/*.txt"
|
|
dest: "{{ remote_tmp_dir }}/archive_pretest_1.tar"
|
|
format: "tar"
|
|
register: pretest_1
|
|
|
|
- name: Archive - pre-test - second run
|
|
archive:
|
|
path: "{{ remote_tmp_dir }}/*.txt"
|
|
dest: "{{ remote_tmp_dir }}/archive_pretest_1.tar"
|
|
format: "tar"
|
|
register: pretest_2
|
|
|
|
- name: Archive - validate pre-test
|
|
assert:
|
|
that:
|
|
- pretest_1 is changed
|
|
- pretest_2 is not changed
|
|
|
|
# Install dependencies
|
|
- name: Ensure zip is present to create test archive (yum)
|
|
yum: name=zip state=latest
|
|
when: ansible_facts.pkg_mgr == 'yum'
|
|
|
|
- name: Ensure zip is present to create test archive (apt)
|
|
apt: name=zip state=latest
|
|
when: ansible_facts.pkg_mgr == 'apt'
|
|
|
|
- name: Define formats to test
|
|
set_fact:
|
|
formats:
|
|
- tar
|
|
- zip
|
|
- gz
|
|
- bz2
|
|
- xz
|
|
|
|
# Run tests
|
|
- name: Run core tests
|
|
include_tasks:
|
|
file: ../tests/core.yml
|
|
loop: "{{ formats }}"
|
|
loop_control:
|
|
loop_var: format
|
|
|
|
- name: Run exclusions tests
|
|
include_tasks:
|
|
file: ../tests/exclusions.yml
|
|
loop: "{{ formats }}"
|
|
loop_control:
|
|
loop_var: format
|
|
|
|
- name: Run remove tests
|
|
include_tasks:
|
|
file: ../tests/remove.yml
|
|
loop: "{{ formats }}"
|
|
loop_control:
|
|
loop_var: format
|
|
|
|
- name: Run broken link tests
|
|
include_tasks:
|
|
file: ../tests/broken-link.yml
|
|
loop: "{{ formats }}"
|
|
loop_control:
|
|
loop_var: format
|
|
|
|
- name: Run Idempotency tests
|
|
include_tasks:
|
|
file: ../tests/idempotency.yml
|
|
loop: "{{ formats }}"
|
|
loop_control:
|
|
loop_var: format
|