mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Split integration tests out from Makefile. (#17976)
This commit is contained in:
parent
bf3d546d9a
commit
80a5c70ad7
169 changed files with 612 additions and 420 deletions
6
test/integration/targets/check_mode/check_mode.yml
Normal file
6
test/integration/targets/check_mode/check_mode.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- hosts: testhost
|
||||
vars:
|
||||
- output_dir: .
|
||||
roles:
|
||||
- { role: test_always_run, tags: test_always_run }
|
||||
- { role: test_check_mode, tags: test_check_mode }
|
|
@ -0,0 +1,18 @@
|
|||
# test code for the always_run option
|
||||
# (c) 2014, James Cammarata <jcammarata@ansible.com>
|
||||
|
||||
# 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/>.
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# test code for the always_run option
|
||||
# (c) 2014, James Cammarata <jcammarata@ansible.com>
|
||||
|
||||
# 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/>.
|
||||
|
||||
- name: run a command while in check mode
|
||||
shell: echo "running"
|
||||
check_mode: no
|
||||
register: result
|
||||
|
||||
- name: assert that the command was run
|
||||
assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.stdout == 'running'"
|
||||
- "result.rc == 0"
|
|
@ -0,0 +1 @@
|
|||
templated_var_loaded
|
|
@ -0,0 +1,50 @@
|
|||
# test code for the template module
|
||||
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
|
||||
# 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/>.
|
||||
|
||||
- name: fill in a basic template in check mode
|
||||
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated mode=0644
|
||||
register: template_result
|
||||
|
||||
- name: check whether file exists
|
||||
stat: path={{output_dir}}/checkmode_foo.templated
|
||||
register: foo
|
||||
|
||||
- name: verify that the file was marked as changed in check mode
|
||||
assert:
|
||||
that:
|
||||
- "template_result|changed"
|
||||
- "not foo.stat.exists"
|
||||
|
||||
- name: Actually create the file, disable check mode
|
||||
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated2 mode=0644
|
||||
check_mode: no
|
||||
register: checkmode_disabled
|
||||
|
||||
- name: fill in template with new content
|
||||
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated2 mode=0644
|
||||
register: template_result2
|
||||
|
||||
- name: remove templated file
|
||||
file: path={{output_dir}}/checkmode_foo.templated2 state=absent
|
||||
check_mode: no
|
||||
|
||||
- name: verify that the file was not changed
|
||||
assert:
|
||||
that:
|
||||
- "checkmode_disabled|changed"
|
||||
- "not template_result2|changed"
|
|
@ -0,0 +1 @@
|
|||
{{ templated_var }}
|
|
@ -0,0 +1 @@
|
|||
templated_var: templated_var_loaded
|
5
test/integration/targets/check_mode/runme.sh
Executable file
5
test/integration/targets/check_mode/runme.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ansible-playbook check_mode.yml -i ../../inventory -v --check "$@"
|
Loading…
Add table
Add a link
Reference in a new issue