mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-07-30 03:14:46 +00:00
Initial commit
This commit is contained in:
89
tests/integration/targets/patch/tasks/main.yml
Normal file
89
tests/integration/targets/patch/tasks/main.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
- name: ensure idempotency installed
|
||||
package:
|
||||
name: patch
|
||||
when: ansible_distribution != "MacOSX"
|
||||
- name: create a directory for the result
|
||||
file:
|
||||
dest: '{{ output_dir }}/patch'
|
||||
state: directory
|
||||
register: result
|
||||
- name: assert the directory was created
|
||||
assert:
|
||||
that:
|
||||
- result.state == 'directory'
|
||||
- name: copy the origin file
|
||||
copy:
|
||||
src: ./origin.txt
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
register: result
|
||||
- name: patch the origin file in check mode
|
||||
check_mode: true
|
||||
register: result
|
||||
community.general.patch:
|
||||
src: result.patch
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
- name: verify patch the origin file in check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: patch the origin file
|
||||
register: result
|
||||
community.general.patch:
|
||||
src: result.patch
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
- name: verify patch the origin file
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: test patch the origin file idempotency
|
||||
register: result
|
||||
community.general.patch:
|
||||
src: result.patch
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
- name: verify test patch the origin file idempotency
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- name: verify the resulted file matches expectations
|
||||
copy:
|
||||
src: ./result.txt
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
register: result
|
||||
failed_when: result is changed
|
||||
- name: patch the workfile file in check mode state absent
|
||||
check_mode: true
|
||||
register: result
|
||||
community.general.patch:
|
||||
src: result.patch
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
state: absent
|
||||
- name: verify patch the workfile file in check mode state absent
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: patch the workfile file state absent
|
||||
register: result
|
||||
community.general.patch:
|
||||
src: result.patch
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
state: absent
|
||||
- name: verify patch the workfile file state absent
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- name: patch the workfile file state absent idempotency
|
||||
register: result
|
||||
community.general.patch:
|
||||
src: result.patch
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
state: absent
|
||||
- name: verify patch the workfile file state absent idempotency
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- name: verify the resulted file matches expectations
|
||||
copy:
|
||||
src: ./origin.txt
|
||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
||||
register: result
|
||||
failed_when: result is changed
|
||||
Reference in New Issue
Block a user