mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-01 05:53:26 -07:00
snap: add param "dangerous" (#6908)
* snap: add param "dangerous" * adjusted run_command out for simple test case * add changelog frag
This commit is contained in:
parent
70503411ee
commit
ea6fb9da8f
7 changed files with 159 additions and 11 deletions
|
@ -5,3 +5,4 @@
|
|||
|
||||
dependencies:
|
||||
- setup_snap
|
||||
- setup_remote_tmp_dir
|
||||
|
|
|
@ -15,3 +15,5 @@
|
|||
ansible.builtin.include_tasks: test.yml
|
||||
- name: Include test_channel
|
||||
ansible.builtin.include_tasks: test_channel.yml
|
||||
- name: Include test_dangerous
|
||||
ansible.builtin.include_tasks: test_dangerous.yml
|
||||
|
|
51
tests/integration/targets/snap/tasks/test_dangerous.yml
Normal file
51
tests/integration/targets/snap/tasks/test_dangerous.yml
Normal file
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
# 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
|
||||
|
||||
- name: Make sure package is not installed (cider)
|
||||
community.general.snap:
|
||||
name: cider
|
||||
state: absent
|
||||
|
||||
- name: Download cider snap
|
||||
ansible.builtin.get_url:
|
||||
url: https://github.com/ciderapp/cider-releases/releases/download/v1.6.0/cider_1.6.0_amd64.snap
|
||||
dest: "{{ remote_tmp_dir }}/cider_1.6.0_amd64.snap"
|
||||
mode: "0644"
|
||||
|
||||
# Test for https://github.com/ansible-collections/community.general/issues/5715
|
||||
- name: Install package from file (check)
|
||||
community.general.snap:
|
||||
name: "{{ remote_tmp_dir }}/cider_1.6.0_amd64.snap"
|
||||
dangerous: true
|
||||
state: present
|
||||
check_mode: true
|
||||
register: install_dangerous_check
|
||||
|
||||
- name: Install package from file
|
||||
community.general.snap:
|
||||
name: "{{ remote_tmp_dir }}/cider_1.6.0_amd64.snap"
|
||||
dangerous: true
|
||||
state: present
|
||||
register: install_dangerous
|
||||
|
||||
- name: Install package from file
|
||||
community.general.snap:
|
||||
name: "{{ remote_tmp_dir }}/cider_1.6.0_amd64.snap"
|
||||
dangerous: true
|
||||
state: present
|
||||
register: install_dangerous_idempot
|
||||
|
||||
- name: Remove package
|
||||
community.general.snap:
|
||||
name: cider
|
||||
state: absent
|
||||
register: remove_dangerous
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- install_dangerous_check is changed
|
||||
- install_dangerous is changed
|
||||
- install_dangerous_idempot is not changed
|
||||
- remove_dangerous is changed
|
|
@ -395,11 +395,46 @@ issue_6803_kubectl_out = (
|
|||
)
|
||||
|
||||
TEST_CASES = [
|
||||
ModuleTestCase(
|
||||
id="simple case",
|
||||
input={"name": ["hello-world"]},
|
||||
output=dict(changed=True, snaps_installed=["hello-world"]),
|
||||
run_command_calls=[
|
||||
RunCmdCall(
|
||||
command=['/testbin/snap', 'info', 'hello-world'],
|
||||
environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False},
|
||||
rc=0,
|
||||
out='name: hello-world\n',
|
||||
err="",
|
||||
),
|
||||
RunCmdCall(
|
||||
command=['/testbin/snap', 'list'],
|
||||
environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False},
|
||||
rc=0,
|
||||
out="",
|
||||
err="",
|
||||
),
|
||||
RunCmdCall(
|
||||
command=['/testbin/snap', 'install', 'hello-world'],
|
||||
environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False},
|
||||
rc=0,
|
||||
out="hello-world (12345/stable) v12345 from Canonical** installed\n",
|
||||
err="",
|
||||
),
|
||||
]
|
||||
),
|
||||
ModuleTestCase(
|
||||
id="issue_6803",
|
||||
input={"name": ["microk8s", "kubectl"], "classic": True},
|
||||
output=dict(changed=True, snaps_installed=["microk8s", "kubectl"]),
|
||||
run_command_calls=[
|
||||
RunCmdCall(
|
||||
command=['/testbin/snap', 'info', 'microk8s', 'kubectl'],
|
||||
environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False},
|
||||
rc=0,
|
||||
out='name: microk8s\n---\nname: kubectl\n',
|
||||
err="",
|
||||
),
|
||||
RunCmdCall(
|
||||
command=['/testbin/snap', 'list'],
|
||||
environ={'environ_update': {'LANGUAGE': 'C', 'LC_ALL': 'C'}, 'check_rc': False},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue