mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Adding tests, corrections
This commit is contained in:
parent
26a968e1f0
commit
9dbedb6d4c
3 changed files with 26 additions and 36 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
minor_changes:
|
minor_changes:
|
||||||
- synchronize - add the ``quiet`` option to supress non-error messages (https://github.com/ansible-collections/ansible.posix/issues/171).
|
- synchronize - add the ``quiet`` option to suppress non-error messages (https://github.com/ansible-collections/ansible.posix/issues/171).
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ def main():
|
||||||
delay_updates=dict(type='bool', default=True),
|
delay_updates=dict(type='bool', default=True),
|
||||||
mode=dict(type='str', default='push', choices=['pull', 'push']),
|
mode=dict(type='str', default='push', choices=['pull', 'push']),
|
||||||
link_dest=dict(type='list', elements='str'),
|
link_dest=dict(type='list', elements='str'),
|
||||||
quiet=dict(type='bool',default=False)
|
quiet=dict(type='bool', default=False)
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
@ -604,7 +604,7 @@ def main():
|
||||||
cmd.append(shlex_quote(source))
|
cmd.append(shlex_quote(source))
|
||||||
cmd.append(shlex_quote(dest))
|
cmd.append(shlex_quote(dest))
|
||||||
if quiet:
|
if quiet:
|
||||||
cmd.append('--quiet')
|
cmd.append('--quiet')
|
||||||
|
|
||||||
cmdstr = ' '.join(cmd)
|
cmdstr = ' '.join(cmd)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,46 +265,36 @@
|
||||||
- directory_a/foo.txt
|
- directory_a/foo.txt
|
||||||
- directory_a
|
- directory_a
|
||||||
- directory_b
|
- directory_b
|
||||||
|
- name: synchronize files with quiet option
|
||||||
- name: setup - test for source with working dir with spaces in path
|
|
||||||
file:
|
|
||||||
state: directory
|
|
||||||
path: '{{output_dir}}/{{item}}'
|
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
|
||||||
with_items:
|
|
||||||
- 'directory a'
|
|
||||||
- 'directory b'
|
|
||||||
- name: setup - create test new files
|
|
||||||
copy:
|
|
||||||
dest: '{{output_dir}}/directory a/{{item}}'
|
|
||||||
mode: '0644'
|
|
||||||
content: 'hello world'
|
|
||||||
with_items:
|
|
||||||
- foo.txt
|
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
|
||||||
- name: copy source with spaces in dir path
|
|
||||||
synchronize:
|
synchronize:
|
||||||
src: '{{output_dir}}/directory a/foo.txt'
|
src: '{{output_dir}}/foo.txt'
|
||||||
dest: '{{output_dir}}/directory b/'
|
dest: '{{output_dir}}/foo.result'
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
quiet: true
|
||||||
register: sync_result
|
register: sync_result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
- name: get stat information for directory_b
|
|
||||||
stat:
|
|
||||||
path: '{{ output_dir }}/directory b/foo.txt'
|
|
||||||
register: stat_result_b
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- '''changed'' in sync_result'
|
- '''--quiet'' in sync_result.cmd'
|
||||||
- sync_result.changed == true
|
|
||||||
- stat_result_b.stat.exists == True
|
|
||||||
- stat_result_b.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: '{{output_dir}}/{{item}}'
|
||||||
with_items:
|
with_items:
|
||||||
- 'directory b/foo.txt'
|
- foo.result
|
||||||
- 'directory a/foo.txt'
|
- bar.result
|
||||||
- 'directory a'
|
- name: synchronize files without quiet option
|
||||||
- 'directory b'
|
synchronize:
|
||||||
|
src: '{{output_dir}}/foo.txt'
|
||||||
|
dest: '{{output_dir}}/foo.result'
|
||||||
|
register: sync_result
|
||||||
|
ignore_errors: true
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- '''--quiet'' not in sync_result.cmd'
|
||||||
|
- name: Cleanup
|
||||||
|
file:
|
||||||
|
state: absent
|
||||||
|
path: '{{output_dir}}/{{item}}'
|
||||||
|
with_items:
|
||||||
|
- foo.result
|
||||||
|
- bar.result
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue