From be433d762b4f704cf5ca155f27d7149d414ed72c Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sun, 27 Feb 2022 13:04:14 +0100 Subject: [PATCH] Add very basic integration tests for pcaman. (#4289) --- tests/integration/targets/pacman/aliases | 7 ++ .../integration/targets/pacman/meta/main.yml | 2 + .../targets/pacman/tasks/basic.yml | 82 +++++++++++++++++++ .../integration/targets/pacman/tasks/main.yml | 10 +++ 4 files changed, 101 insertions(+) create mode 100644 tests/integration/targets/pacman/aliases create mode 100644 tests/integration/targets/pacman/meta/main.yml create mode 100644 tests/integration/targets/pacman/tasks/basic.yml create mode 100644 tests/integration/targets/pacman/tasks/main.yml diff --git a/tests/integration/targets/pacman/aliases b/tests/integration/targets/pacman/aliases new file mode 100644 index 0000000000..817614d6a7 --- /dev/null +++ b/tests/integration/targets/pacman/aliases @@ -0,0 +1,7 @@ +destructive +shippable/posix/group1 +skip/aix +skip/freebsd +skip/osx +skip/macos +skip/rhel diff --git a/tests/integration/targets/pacman/meta/main.yml b/tests/integration/targets/pacman/meta/main.yml new file mode 100644 index 0000000000..1810d4bec9 --- /dev/null +++ b/tests/integration/targets/pacman/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/tests/integration/targets/pacman/tasks/basic.yml b/tests/integration/targets/pacman/tasks/basic.yml new file mode 100644 index 0000000000..eac3bc4eec --- /dev/null +++ b/tests/integration/targets/pacman/tasks/basic.yml @@ -0,0 +1,82 @@ +--- +- vars: + package_name: unarj + block: + - name: Make sure that {{ package_name }} is not installed + pacman: + name: '{{ package_name }}' + state: absent + + - name: Install {{ package_name }} (check mode) + pacman: + name: '{{ package_name }}' + state: present + check_mode: true + register: install_1 + + - name: Install {{ package_name }} + pacman: + name: '{{ package_name }}' + state: present + register: install_2 + + - name: Install {{ package_name }} (check mode, idempotent) + pacman: + name: '{{ package_name }}' + state: present + check_mode: true + register: install_3 + + - name: Install {{ package_name }} (idempotent) + pacman: + name: '{{ package_name }}' + state: present + register: install_4 + + - assert: + that: + - install_1 is changed + - install_1.msg == 'Would have installed 1 packages' + - install_2 is changed + - install_2.msg == 'Installed 1 package(s)' + - install_3 is not changed + - install_3.msg == 'package(s) already installed' + - install_4 is not changed + - install_4.msg == 'package(s) already installed' + + - name: Uninstall {{ package_name }} (check mode) + pacman: + name: '{{ package_name }}' + state: absent + check_mode: true + register: uninstall_1 + + - name: Uninstall {{ package_name }} + pacman: + name: '{{ package_name }}' + state: absent + register: uninstall_2 + + - name: Uninstall {{ package_name }} (check mode, idempotent) + pacman: + name: '{{ package_name }}' + state: absent + check_mode: true + register: uninstall_3 + + - name: Uninstall {{ package_name }} (idempotent) + pacman: + name: '{{ package_name }}' + state: absent + register: uninstall_4 + + - assert: + that: + - uninstall_1 is changed + - uninstall_1.msg == 'Would have removed 1 packages' + - uninstall_2 is changed + - uninstall_2.msg == 'Removed 1 package(s)' + - uninstall_3 is not changed + - uninstall_3.msg == 'package(s) already absent' + - uninstall_4 is not changed + - uninstall_4.msg == 'package(s) already absent' diff --git a/tests/integration/targets/pacman/tasks/main.yml b/tests/integration/targets/pacman/tasks/main.yml new file mode 100644 index 0000000000..02b4035317 --- /dev/null +++ b/tests/integration/targets/pacman/tasks/main.yml @@ -0,0 +1,10 @@ +--- +#################################################################### +# WARNING: These are designed specifically for Ansible tests # +# and should not be used as examples of how to write Ansible roles # +#################################################################### + +- when: ansible_os_family == 'Archlinux' + block: + # Add more tests here by including more task files: + - include: 'basic.yml'