# Test copying to a source directory that contains only a single file in a deeper structure

- name: Ensure that dest top directory doesn't exist
  file:
    path: '{{ remote_dir }}/subdir_with_deep_single_file'
    state: absent

- name: Copy subdir_with_deep_single_file directory which contains a single file
  copy:
    src: subdir_with_deep_single_file
    dest: '{{ remote_dir }}'
  register: copy_result

- name: Debug copy result
  debug:
    var: copy_result
    verbosity: 1

- name: Check the transferred file
  stat:
    path: '{{ remote_dir }}/subdir_with_deep_single_file/dir/file.txt'
  register: stat_file

- name: Assert that transferred file exists and copy_result is as expected for deeper structure
  assert:
    that:
      - 'stat_file.stat.exists'
      - 'copy_result.changed'
      - 'copy_result.dest == remote_dir + "/subdir_with_deep_single_file/dir/file.txt"'
