mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Use the new "list" format of the assert to make things more readable, name every task.
This commit is contained in:
parent
54117ab28f
commit
0d64159d03
1 changed files with 29 additions and 15 deletions
|
@ -16,7 +16,8 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- set_fact: output_file={{output_dir}}/foo.txt
|
- name: record the output directory
|
||||||
|
set_fact: output_file={{output_dir}}/foo.txt
|
||||||
|
|
||||||
- name: initiate a basic copy
|
- name: initiate a basic copy
|
||||||
copy: src=foo.txt dest={{output_file}}
|
copy: src=foo.txt dest={{output_file}}
|
||||||
|
@ -38,10 +39,14 @@
|
||||||
|
|
||||||
|
|
||||||
- name: verify that the file was marked as changed
|
- name: verify that the file was marked as changed
|
||||||
assert: { that: "copy_result.changed == true" }
|
assert:
|
||||||
|
that:
|
||||||
|
- "copy_result.changed == true"
|
||||||
|
|
||||||
- name: verify that the file md5sum is correct
|
- name: verify that the file md5sum is correct
|
||||||
assert: { that: "copy_result.md5sum == 'c47397529fe81ab62ba3f85e9f4c71f2'" }
|
assert:
|
||||||
|
that:
|
||||||
|
- "copy_result.md5sum == 'c47397529fe81ab62ba3f85e9f4c71f2'"
|
||||||
|
|
||||||
- name: check the stat results of the file
|
- name: check the stat results of the file
|
||||||
stat: path={{output_file}}
|
stat: path={{output_file}}
|
||||||
|
@ -49,33 +54,42 @@
|
||||||
|
|
||||||
- debug: var=stat_results
|
- debug: var=stat_results
|
||||||
|
|
||||||
- assert: { that: "stat_results.stat.exists == true" }
|
- name: assert the stat results are correct
|
||||||
- assert: { that: "stat_results.stat.isblk == false" }
|
assert:
|
||||||
- assert: { that: "stat_results.stat.isfifo == false" }
|
that:
|
||||||
- assert: { that: "stat_results.stat.isreg == true" }
|
- "stat_results.stat.exists == true"
|
||||||
- assert: { that: "stat_results.stat.issock == false" }
|
- "stat_results.stat.isblk == false"
|
||||||
- assert: { that: "stat_results.stat.md5 == 'c47397529fe81ab62ba3f85e9f4c71f2'" }
|
- "stat_results.stat.isfifo == false"
|
||||||
|
- "stat_results.stat.isreg == true"
|
||||||
|
- "stat_results.stat.issock == false"
|
||||||
|
- "stat_results.stat.md5 == 'c47397529fe81ab62ba3f85e9f4c71f2'"
|
||||||
|
|
||||||
- name: overwrite the file via same means
|
- name: overwrite the file via same means
|
||||||
copy: src=foo.txt dest={{output_file}}
|
copy: src=foo.txt dest={{output_file}}
|
||||||
register: copy_result2
|
register: copy_result2
|
||||||
|
|
||||||
- name: verify the copy was marked unchanged
|
- name: assert that the file was not changed
|
||||||
assert: { that: "not copy_result2|changed" }
|
assert:
|
||||||
|
that:
|
||||||
|
- "not copy_result2|changed"
|
||||||
|
|
||||||
- name: overwrite the file using the content system
|
- name: overwrite the file using the content system
|
||||||
copy: content="modified" dest={{output_file}}
|
copy: content="modified" dest={{output_file}}
|
||||||
register: copy_result3
|
register: copy_result3
|
||||||
|
|
||||||
- name: verify the copy result was marked changed
|
- name: assert that the file has changed
|
||||||
assert: { that: "copy_result3|changed" }
|
assert:
|
||||||
|
that:
|
||||||
|
- "copy_result3|changed"
|
||||||
|
|
||||||
- name: overwrite the file again using the content system
|
- name: overwrite the file again using the content system
|
||||||
copy: content="modified" dest={{output_file}}
|
copy: content="modified" dest={{output_file}}
|
||||||
register: copy_result4
|
register: copy_result4
|
||||||
|
|
||||||
- name: verify the copy result was marked unchanged
|
- name: assert that the copy result has not changed
|
||||||
assert: { that: "not copy_result4|changed" }
|
assert:
|
||||||
|
that:
|
||||||
|
- "not copy_result4|changed"
|
||||||
|
|
||||||
# TODO: test recursive copy
|
# TODO: test recursive copy
|
||||||
# TODO: test copy where destination is a directory like {{output_dir}}/
|
# TODO: test copy where destination is a directory like {{output_dir}}/
|
||||||
|
|
Loading…
Reference in a new issue