parent
2f6b8591b1
commit
a3a189fc83
6 changed files with 264 additions and 0 deletions
7
test/integration/targets/flatpak_remote/aliases
Normal file
7
test/integration/targets/flatpak_remote/aliases
Normal file
|
@ -0,0 +1,7 @@
|
|||
unsupported
|
||||
destructive
|
||||
skip/freebsd
|
||||
skip/osx
|
||||
skip/rhel
|
||||
needs/root
|
||||
needs/privileged
|
2
test/integration/targets/flatpak_remote/meta/main.yml
Normal file
2
test/integration/targets/flatpak_remote/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_tests
|
101
test/integration/targets/flatpak_remote/tasks/check_mode.yml
Normal file
101
test/integration/targets/flatpak_remote/tasks/check_mode.yml
Normal file
|
@ -0,0 +1,101 @@
|
|||
# - Tests with absent flatpak remote -------------------------------------------
|
||||
|
||||
# state=present
|
||||
|
||||
- name: Test addition of absent flatpak remote (check mode)
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
state: present
|
||||
register: addition_result
|
||||
check_mode: true
|
||||
|
||||
- name: Verify addition of absent flatpak remote test result (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "addition_result.changed == true"
|
||||
msg: "Adding an absent flatpak remote shall mark module execution as changed"
|
||||
|
||||
- name: Test non-existent idempotency of addition of absent flatpak remote (check mode)
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
state: present
|
||||
register: double_addition_result
|
||||
check_mode: true
|
||||
|
||||
- name: >
|
||||
Verify non-existent idempotency of addition of absent flatpak remote
|
||||
test result (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "double_addition_result.changed == true"
|
||||
msg: |
|
||||
Adding an absent flatpak remote a second time shall still mark module execution
|
||||
as changed in check mode
|
||||
|
||||
# state=absent
|
||||
|
||||
- name: Test removal of absent flatpak remote not doing anything in check mode
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
state: absent
|
||||
register: removal_result
|
||||
check_mode: true
|
||||
|
||||
- name: Verify removal of absent flatpak remote test result (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "removal_result.changed == false"
|
||||
msg: "Removing an absent flatpak remote shall mark module execution as not changed"
|
||||
|
||||
|
||||
# - Tests with present flatpak remote -------------------------------------------
|
||||
|
||||
# state=present
|
||||
|
||||
- name: Test addition of present flatpak remote (check mode)
|
||||
flatpak_remote:
|
||||
name: check-mode-test-remote
|
||||
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
state: present
|
||||
register: addition_result
|
||||
check_mode: true
|
||||
|
||||
- name: Verify addition of present flatpak remote test result (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "addition_result.changed == false"
|
||||
msg: "Adding a present flatpak remote shall mark module execution as not changed"
|
||||
|
||||
# state=absent
|
||||
|
||||
- name: Test removal of present flatpak remote not doing anything in check mode
|
||||
flatpak_remote:
|
||||
name: check-mode-test-remote
|
||||
state: absent
|
||||
register: removal_result
|
||||
check_mode: true
|
||||
|
||||
- name: Verify removal of present flatpak remote test result (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "removal_result.changed == true"
|
||||
msg: "Removing a present flatpak remote shall mark module execution as changed"
|
||||
|
||||
- name: Test non-existent idempotency of removal of present flatpak remote (check mode)
|
||||
flatpak_remote:
|
||||
name: check-mode-test-remote
|
||||
state: absent
|
||||
register: double_removal_result
|
||||
check_mode: true
|
||||
|
||||
- name: >
|
||||
Verify non-existent idempotency of removal of present flatpak remote
|
||||
test result (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "double_removal_result.changed == true"
|
||||
msg: |
|
||||
Removing a present flatpak remote a second time shall still mark module execution
|
||||
as changed in check mode
|
56
test/integration/targets/flatpak_remote/tasks/main.yml
Normal file
56
test/integration/targets/flatpak_remote/tasks/main.yml
Normal file
|
@ -0,0 +1,56 @@
|
|||
# (c) 2018, Alexander Bethke <oolongbrothers@gmx.net>
|
||||
# (c) 2018, Ansible Project
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- block:
|
||||
|
||||
- import_tasks: setup.yml
|
||||
become: true
|
||||
|
||||
# executable override
|
||||
|
||||
- name: Test executable override
|
||||
flatpak:
|
||||
name: org.gnome.Characters
|
||||
remote: flathub
|
||||
state: present
|
||||
executable: nothing-that-exists
|
||||
ignore_errors: true
|
||||
register: executable_override_result
|
||||
|
||||
- name: Verify executable override test result
|
||||
assert:
|
||||
that:
|
||||
- "executable_override_result.failed == true"
|
||||
- "executable_override_result.changed == false"
|
||||
msg: "Specifying non-existing executable shall fail module execution"
|
||||
|
||||
- import_tasks: check_mode.yml
|
||||
become: false
|
||||
|
||||
- import_tasks: test.yml
|
||||
become: false
|
||||
vars:
|
||||
method: user
|
||||
|
||||
- import_tasks: test.yml
|
||||
become: true
|
||||
vars:
|
||||
method: system
|
||||
|
||||
when: |
|
||||
ansible_distribution in ('Fedora', 'Ubuntu')
|
26
test/integration/targets/flatpak_remote/tasks/setup.yml
Normal file
26
test/integration/targets/flatpak_remote/tasks/setup.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
- name: Install flatpak on Fedora
|
||||
dnf:
|
||||
name: flatpak
|
||||
state: present
|
||||
|
||||
when: ansible_distribution == 'Fedora'
|
||||
|
||||
- block:
|
||||
- name: Activate flatpak ppa on Ubuntu
|
||||
apt_repository:
|
||||
repo: "ppa:alexlarsson/flatpak"
|
||||
state: present
|
||||
mode: 0644
|
||||
|
||||
- name: Install flatpak package on Ubuntu
|
||||
apt:
|
||||
name: flatpak
|
||||
state: present
|
||||
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
|
||||
- name: Install flatpak_remote for testing check mode
|
||||
flatpak_remote:
|
||||
name: check-mode-test-remote
|
||||
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
state: present
|
72
test/integration/targets/flatpak_remote/tasks/test.yml
Normal file
72
test/integration/targets/flatpak_remote/tasks/test.yml
Normal file
|
@ -0,0 +1,72 @@
|
|||
# state=present
|
||||
|
||||
- name: Test addition - {{ method }}
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
state: present
|
||||
method: "{{ method }}"
|
||||
register: addition_result
|
||||
|
||||
- name: Verify addition test result - {{ method }}
|
||||
assert:
|
||||
that:
|
||||
- "addition_result.changed == true"
|
||||
msg: "state=preset shall add flatpak when absent"
|
||||
|
||||
- name: Test idempotency of addition - {{ method }}
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
state: present
|
||||
method: "{{ method }}"
|
||||
register: double_addition_result
|
||||
|
||||
- name: Verify idempotency of addition test result - {{ method }}
|
||||
assert:
|
||||
that:
|
||||
- "double_addition_result.changed == false"
|
||||
msg: "state=present shall not do anything when flatpak is already present"
|
||||
|
||||
- name: Test updating remote url does not do anything - {{ method }}
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
flatpakrepo_url: https://a.different/repo.flatpakrepo
|
||||
state: present
|
||||
method: "{{ method }}"
|
||||
register: url_update_result
|
||||
|
||||
- name: Verify updating remote url does not do anything - {{ method }}
|
||||
assert:
|
||||
that:
|
||||
- "url_update_result.changed == false"
|
||||
msg: "Trying to update the URL of an existing flatpak remote shall not do anything"
|
||||
|
||||
|
||||
# state=absent
|
||||
|
||||
- name: Test removal - {{ method }}
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
state: absent
|
||||
method: "{{ method }}"
|
||||
register: removal_result
|
||||
|
||||
- name: Verify removal test result - {{ method }}
|
||||
assert:
|
||||
that:
|
||||
- "removal_result.changed == true"
|
||||
msg: "state=absent shall remove flatpak when present"
|
||||
|
||||
- name: Test idempotency of removal - {{ method }}
|
||||
flatpak_remote:
|
||||
name: flatpak-test
|
||||
state: absent
|
||||
method: "{{ method }}"
|
||||
register: double_removal_result
|
||||
|
||||
- name: Verify idempotency of removal test result - {{ method }}
|
||||
assert:
|
||||
that:
|
||||
- "double_removal_result.changed == false"
|
||||
msg: "state=absent shall not do anything when flatpak is not present"
|
Loading…
Reference in a new issue