summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/win_get_url
diff options
context:
space:
mode:
authorjhawkesworth <jhawkesworth@users.noreply.github.com>2017-07-10 06:30:55 +0200
committerJordan Borean <jborean93@gmail.com>2017-07-10 06:30:55 +0200
commitdeae1499ed66a732432876e412bf2f0d6208b4dd (patch)
treee15c1178931de14e133b56ff3ceca3f63e296ea2 /test/integration/targets/win_get_url
parentwin_chocolatey: Add -skip-scripts support (#26523) (diff)
downloadansible-deae1499ed66a732432876e412bf2f0d6208b4dd.tar.xz
ansible-deae1499ed66a732432876e412bf2f0d6208b4dd.zip
win_get_url improvements; allow dir for dest and helpful error if dest parent dir doesn't exist (#25453)
* win_get_url now allows dir for destination and gives helpful message if download parent dir does not exist * fix yaml lint failure
Diffstat (limited to 'test/integration/targets/win_get_url')
-rw-r--r--test/integration/targets/win_get_url/defaults/main.yml8
-rw-r--r--test/integration/targets/win_get_url/tasks/main.yml34
2 files changed, 37 insertions, 5 deletions
diff --git a/test/integration/targets/win_get_url/defaults/main.yml b/test/integration/targets/win_get_url/defaults/main.yml
index 28e5de659f..c912ed24e8 100644
--- a/test/integration/targets/win_get_url/defaults/main.yml
+++ b/test/integration/targets/win_get_url/defaults/main.yml
@@ -1,6 +1,8 @@
---
-test_win_get_url_link: https://www.redhat.com
+test_win_get_url_host: www.redhat.com
+test_win_get_url_link: "https://{{test_win_get_url_host}}"
test_win_get_url_invalid_link: https://www.redhat.com/skynet_module.html
-test_win_get_url_invalid_path: "Q:\\Filez\\Cyberdyne.html"
-test_win_get_url_path: "{{ test_win_get_url_dir_path }}\\docs_index.html" \ No newline at end of file
+test_win_get_url_invalid_path: 'Q:\Filez\Cyberdyne.html'
+test_win_get_url_invalid_path_dir: 'Q:\Filez\'
+test_win_get_url_path: '{{ test_win_get_url_dir_path }}\docs_index.html'
diff --git a/test/integration/targets/win_get_url/tasks/main.yml b/test/integration/targets/win_get_url/tasks/main.yml
index 17482fcd4c..9e818e318b 100644
--- a/test/integration/targets/win_get_url/tasks/main.yml
+++ b/test/integration/targets/win_get_url/tasks/main.yml
@@ -99,7 +99,37 @@
register: win_get_url_result_dir_path
ignore_errors: true
-- name: check that the download failed if dest is a directory
+- name: check that the download did NOT fail, even though dest was directory
assert:
that:
- - "win_get_url_result_dir_path|failed"
+ - "win_get_url_result_dir_path|changed"
+
+- name: test win_get_url with a valid url path and a dest that is a directory (from 2.4 should use url path as filename)
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_dir_path}}"
+ register: win_get_url_result_dir_path_urlpath
+ ignore_errors: true
+
+- name: set expected destination path fact
+ set_fact:
+ expected_dest_path: '{{test_win_get_url_dir_path}}\{{test_win_get_url_host}}'
+
+- name: check that the download succeeded (changed) and dest is as expected
+ assert:
+ that:
+ - "win_get_url_result_dir_path_urlpath|changed"
+ - "win_get_url_result_dir_path_urlpath.win_get_url.actual_dest==expected_dest_path"
+
+- name: since 2.4 check you get a helpful message if the parent folder of the dest doesnt exist
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_invalid_path_dir}}"
+ register: win_get_url_result_invalid_dest
+ ignore_errors: true
+
+- name: check if dest parent dir does not exist, module fails and you get a specific error message
+ assert:
+ that:
+ - "win_get_url_result_invalid_dest|failed"
+ - "win_get_url_result_invalid_dest.msg is search('does not exist')"