From b46c0985813b9b2e2b1d6b4472bdf4f0904bdc5f Mon Sep 17 00:00:00 2001 From: jhawkesworth Date: Tue, 23 May 2017 18:57:24 +0100 Subject: [PATCH] Added win_copy recursive integration test with trailing path separator. (#24523) This is a reproducer for https://github.com/ansible/ansible/issues/23559 Tests will fail until https://github.com/ansible/ansible/pull/23581 is merged Note that I believe another commit is also needed for this to work, specifically the change from: https://github.com/ansible/ansible/pull/23326 --- .../targets/win_copy/tasks/main.yml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/integration/targets/win_copy/tasks/main.yml b/test/integration/targets/win_copy/tasks/main.yml index e4fc6a2dbb6..3e7e2b2a593 100644 --- a/test/integration/targets/win_copy/tasks/main.yml +++ b/test/integration/targets/win_copy/tasks/main.yml @@ -162,6 +162,50 @@ that: - not recursive_copy_result_again|changed +# Recursive folder copy with trailing slash (see issue 23559) + + +- name: make an output subdirectory + win_file: + path: "{{win_output_dir}}\\subtrailing\\" + state: directory + +- name: test recursive copy to directory + win_copy: + src: subdir/ + dest: "{{win_output_dir}}\\subtrailing\\" + register: recursive_copy_result2 + +- name: get stats on files within sub directory + win_find: + paths: "{{win_output_dir}}\\subtrailing\\" + recurse: True + register: recurse_find_results2 + +- name: assert recursive copy worked + assert: + that: + - recursive_copy_result2|changed + - recurse_find_results2.examined == 6 # checks that it found 3 folders and 3 files. +# Note this is different from the test above because, by including the trailing +# slash on the source, we only get the *contents* of the source folder +# without the trailing slash, we would get the source folder *and* its +# contents. +# See 'src' parameter documentation +# here: http://docs.ansible.com/ansible/win_copy_module.html + +- name: test recursive copy to directory again with source slash + win_copy: + src: subdir/ + dest: "{{win_output_dir}}\\subtrailing\\" + register: recursive_copy_result_again2 + +- name: assert recursive copy worked + assert: + that: + - not recursive_copy_result_again2|changed + +# test 'content' parameter - name: create file with content win_copy: content: abc