add tests

pull/83445/head
Simon Leary 1 year ago
parent 8cf62a7358
commit bb947d129b

@ -23,6 +23,51 @@
dest: '{{remote_tmp_dir_test}}/file_to_link'
content: 'Hello World'
#
# edge cases that came up in the `copy` integration tests but not `file`
#
- name: create a new directory with a relative destination path
file:
path: "{{ lookup('password', '/dev/null', length=10) }}"
state: directory
register: relative_temp_dir
- name: create a new directory with a destination path that ends in a slash
file:
path: '{{ remote_tmp_dir_test }}/ends_with_slash/'
state: directory
- name: cleanup
file:
path: "{{ item }}"
state: absent
loop:
- '{{ relative_temp_dir.path }}'
- '{{ remote_tmp_dir_test }}/ends_with_slash/'
#
# verify diff output
#
- name: make a directory and its parent directory
file:
path: "{{ remote_tmp_dir }}/foo/bar"
state: directory
diff: true
register: make_2_dirs
- name: assert that both foo and foo/bar have their own diffs
assert:
that:
- (make_2_dirs.diff | length) == 2
- (make_2_dirs.diff | map(attribute='after') | map(attribute='path') | sort) == ["{{ remote_tmp_dir }}/foo", "{{ remote_tmp_dir }}/foo/bar"]
- name: cleanup
file:
path: "{{ remote_tmp_dir }}/foo"
state: absent
#
# Error condtion: specify a directory with state={link,file}, force=False
#

@ -397,6 +397,25 @@
- name: change the ownership of a directory with recurse=yes
file: path={{remote_tmp_dir_test}}/foobar owner=1235 recurse=yes
- name: copy directory for diff test
copy:
src: diff-test
dest: "{{remote_tmp_dir_test}}/"
owner: 1234
- name: change the owner on the diff test files
file:
path: "{{remote_tmp_dir_test}}/diff-test"
owner: 1235
recurse: true
register: change_ownership_recurse
- name: verify that both the directory and the file have diffs
assert:
that:
- (change_ownership_recurse.diff | length) == 2
- (change_ownership_recurse.diff | map(attribute='after') | map(attribute='path') | sort) == ["{{remote_tmp_dir_test}}/diff-test", "{{remote_tmp_dir_test}}/diff-test/file"]
- name: verify that the permission of the directory was set
file: path={{remote_tmp_dir_test}}/foobar state=directory
register: file10_result

Loading…
Cancel
Save