summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/file
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2019-06-05 15:26:40 +0200
committerGitHub <noreply@github.com>2019-06-05 15:26:40 +0200
commit18f2ed63e057667a21ea7194e3c100cb0af80026 (patch)
tree245fac648ca805f93b11b6730eba884312abe6e1 /test/integration/targets/file
parentfile: fix setting attributes for symlinked file (#57217) (diff)
downloadansible-18f2ed63e057667a21ea7194e3c100cb0af80026.tar.xz
ansible-18f2ed63e057667a21ea7194e3c100cb0af80026.zip
file: fix setting relative paths for src for hard links (#56055)
Diffstat (limited to 'test/integration/targets/file')
-rw-r--r--test/integration/targets/file/tasks/main.yml74
1 files changed, 68 insertions, 6 deletions
diff --git a/test/integration/targets/file/tasks/main.yml b/test/integration/targets/file/tasks/main.yml
index 52957fff05..2c473329d2 100644
--- a/test/integration/targets/file/tasks/main.yml
+++ b/test/integration/targets/file/tasks/main.yml
@@ -563,9 +563,6 @@
stat: path={{output_dir}}/test_follow_rec_target_dir/foo
register: file_in_dir_result
-- debug: var=file_result.stat.mode
-- debug: var=dir_result.stat.mode
-- debug: var=file_in_dir_result.stat.mode
- name: assert that the link targets were unmodified
assert:
that:
@@ -588,12 +585,77 @@
stat: path={{output_dir}}/test_follow_rec_target_dir/foo
register: file_in_dir_result
-- debug: var=file_result.stat.mode
-- debug: var=dir_result.stat.mode
-- debug: var=file_in_dir_result.stat.mode
- name: assert that the link targets were modified
assert:
that:
- file_result.stat.mode == '0600'
- dir_result.stat.mode == '0600'
- file_in_dir_result.stat.mode == '0600'
+
+# https://github.com/ansible/ansible/issues/55971
+- name: Test missing src and path
+ file:
+ state: hard
+ register: file_error1
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "file_error1 is failed"
+ - "file_error1.msg == 'missing required arguments: path'"
+
+- name: Test missing src
+ file:
+ dest: "{{ output_dir }}/hard.txt"
+ state: hard
+ register: file_error2
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "file_error2 is failed"
+ - "file_error2.msg == 'src is required for creating new hardlinks'"
+
+- name: Test non-existing src
+ file:
+ src: non-existing-file-that-does-not-exist.txt
+ dest: "{{ output_dir }}/hard.txt"
+ state: hard
+ register: file_error3
+ ignore_errors: yes
+
+- assert:
+ that:
+ - "file_error3 is failed"
+ - "file_error3.msg == 'src does not exist'"
+ - "file_error3.dest == '{{ output_dir }}/hard.txt' | expanduser"
+ - "file_error3.src == 'non-existing-file-that-does-not-exist.txt'"
+
+- block:
+ - name: Create a testing file
+ file:
+ dest: original_file.txt
+ state: touch
+
+ - name: Test relative path with state=hard
+ file:
+ src: original_file.txt
+ dest: hard_link_file.txt
+ state: hard
+ register: hard_link_relpath
+
+ - name: Just check if it was successful, we don't care about the actual hard link in this test
+ assert:
+ that:
+ - "hard_link_relpath is success"
+
+ always:
+ - name: Clean up
+ file:
+ path: "{{ item }}"
+ state: absent
+ loop:
+ - original_file.txt
+ - hard_link_file.txt
+
+# END #55971