tests, patch: init integration tests (#40045)
* patch: init integration tests * skip install for macos
This commit is contained in:
parent
27942d937f
commit
4a1632444b
6 changed files with 168 additions and 0 deletions
2
test/integration/targets/patch/aliases
Normal file
2
test/integration/targets/patch/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
destructive
|
||||
posix/ci/group2
|
19
test/integration/targets/patch/files/origin.txt
Normal file
19
test/integration/targets/patch/files/origin.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
Stet clita kasd gubergren,no sea takimata sanctus est Lorem ipsum dolor
|
||||
sit amet.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum.
|
||||
|
||||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
|
||||
sit amet.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum.
|
||||
|
||||
Stet clita kasd gubergren,no sea takimata sanctus est Lorem ipsum dolor
|
||||
sit amet.
|
24
test/integration/targets/patch/files/result.patch
Normal file
24
test/integration/targets/patch/files/result.patch
Normal file
|
@ -0,0 +1,24 @@
|
|||
--- origin.txt 2018-05-12 10:22:14.155109584 +0200
|
||||
+++ result.txt 2018-05-12 10:18:07.230811204 +0200
|
||||
@@ -2,18 +2,12 @@
|
||||
sit amet.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
-tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
-vero eos et accusam et justo duo dolores et ea rebum.
|
||||
-
|
||||
-Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
|
||||
-sit amet.
|
||||
-
|
||||
-Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
-tempor invidunt ut labore et dolore magna aliquyam erat.
|
||||
+tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
+At vero eos et accusam et justo duo dolores et ea rebum.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum.
|
||||
|
||||
-Stet clita kasd gubergren,no sea takimata sanctus est Lorem ipsum dolor
|
||||
+Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
|
||||
sit amet.
|
13
test/integration/targets/patch/files/result.txt
Normal file
13
test/integration/targets/patch/files/result.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
Stet clita kasd gubergren,no sea takimata sanctus est Lorem ipsum dolor
|
||||
sit amet.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
|
||||
At vero eos et accusam et justo duo dolores et ea rebum.
|
||||
|
||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
|
||||
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
|
||||
vero eos et accusam et justo duo dolores et ea rebum.
|
||||
|
||||
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor
|
||||
sit amet.
|
3
test/integration/targets/patch/meta/main.yml
Normal file
3
test/integration/targets/patch/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- prepare_tests
|
107
test/integration/targets/patch/tasks/main.yml
Normal file
107
test/integration/targets/patch/tasks/main.yml
Normal file
|
@ -0,0 +1,107 @@
|
|||
---
|
||||
- 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
|
||||
patch:
|
||||
src: result.patch
|
||||
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||
check_mode: yes
|
||||
register: result
|
||||
|
||||
- name: verify patch the origin file in check mode
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: patch the origin file
|
||||
patch:
|
||||
src: result.patch
|
||||
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||
register: result
|
||||
|
||||
- name: verify patch the origin file
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: test patch the origin file idempotency
|
||||
patch:
|
||||
src: result.patch
|
||||
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||
register: result
|
||||
|
||||
- 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
|
||||
patch:
|
||||
src: result.patch
|
||||
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
register: result
|
||||
|
||||
- name: verify patch the workfile file in check mode state absent
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: patch the workfile file state absent
|
||||
patch:
|
||||
src: result.patch
|
||||
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: verify patch the workfile file state absent
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: patch the workfile file state absent idempotency
|
||||
patch:
|
||||
src: result.patch
|
||||
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- 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
|
Loading…
Reference in a new issue