mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Add more tests for copy/file/template with harlinks
This commit is contained in:
parent
2b14fdbce3
commit
bc66faa328
3 changed files with 126 additions and 20 deletions
|
@ -163,10 +163,79 @@
|
|||
state: hard
|
||||
|
||||
- name: copy the same contents into place
|
||||
copy:
|
||||
content: 'modified'
|
||||
dest: '{{ remote_file }}'
|
||||
mode: 0700
|
||||
register: copy_results
|
||||
|
||||
- name: Check the stat results of the file
|
||||
stat:
|
||||
path: "{{ remote_file }}"
|
||||
register: stat_results
|
||||
|
||||
- name: Check the stat results of the hard link
|
||||
stat:
|
||||
path: "{{ output_dir }}/hard.lnk"
|
||||
register: hlink_results
|
||||
|
||||
- name: Check that the file did not change
|
||||
assert:
|
||||
that:
|
||||
- 'stat_results.stat.inode == hlink_results.stat.inode'
|
||||
- 'copy_results.changed == False'
|
||||
- "stat_results.stat.checksum == ('modified'|hash('sha1'))"
|
||||
|
||||
- name: copy the same contents into place but change mode
|
||||
copy:
|
||||
content: 'modified'
|
||||
dest: '{{ remote_file }}'
|
||||
mode: 0404
|
||||
register: copy_results
|
||||
|
||||
- name: Check the stat results of the file
|
||||
stat:
|
||||
path: "{{ remote_file }}"
|
||||
register: stat_results
|
||||
|
||||
- name: Check the stat results of the hard link
|
||||
stat:
|
||||
path: "{{ output_dir }}/hard.lnk"
|
||||
register: hlink_results
|
||||
|
||||
- name: Check that the file changed permissions but is still the same
|
||||
assert:
|
||||
that:
|
||||
- 'stat_results.stat.inode == hlink_results.stat.inode'
|
||||
- 'copy_results.changed == True'
|
||||
- 'stat_results.stat.mode == hlink_results.stat.mode'
|
||||
- 'stat_results.stat.mode == "0404"'
|
||||
- "stat_results.stat.checksum == ('modified'|hash('sha1'))"
|
||||
|
||||
- name: copy the different contents into place
|
||||
copy:
|
||||
content: 'adjusted'
|
||||
dest: '{{ remote_file }}'
|
||||
mode: 0404
|
||||
register: copy_results
|
||||
|
||||
- name: Check the stat results of the file
|
||||
stat:
|
||||
path: "{{ remote_file }}"
|
||||
register: stat_results
|
||||
|
||||
- name: Check the stat results of the hard link
|
||||
stat:
|
||||
path: "{{ output_dir }}/hard.lnk"
|
||||
register: hlink_results
|
||||
|
||||
- name: Check that the file changed and hardlink was broken
|
||||
assert:
|
||||
that:
|
||||
- 'stat_results.stat.inode != hlink_results.stat.inode'
|
||||
- 'copy_results.changed == True'
|
||||
- "stat_results.stat.checksum == ('adjusted'|hash('sha1'))"
|
||||
- "hlink_results.stat.checksum == ('modified'|hash('sha1'))"
|
||||
|
||||
- name: Try invalid copy input location fails
|
||||
copy:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue