summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2015-07-10 17:07:20 -0400
committerBrian Coca <bcoca@ansible.com>2015-07-10 17:07:20 -0400
commitb4de103bb235d22ccb6e7caff6b1a24df856e66e (patch)
treee334e246fcda7b3638f8401fc53c973f72bb517d
parentc6dde19a5e2847d685c3b350b47690f0d0ea380a (diff)
parent1aa2191fd55a627a1ca867228498d5b1d24ae629 (diff)
downloadansible-b4de103bb235d22ccb6e7caff6b1a24df856e66e.tar.gz
Merge pull request #11555 from cchurch/test_win_get_url_updates
Update tests for win_get_url module to test force parameter
-rw-r--r--test/integration/roles/test_win_get_url/defaults/main.yml7
-rw-r--r--test/integration/roles/test_win_get_url/tasks/main.yml76
2 files changed, 76 insertions, 7 deletions
diff --git a/test/integration/roles/test_win_get_url/defaults/main.yml b/test/integration/roles/test_win_get_url/defaults/main.yml
new file mode 100644
index 0000000000..6e507ecf31
--- /dev/null
+++ b/test/integration/roles/test_win_get_url/defaults/main.yml
@@ -0,0 +1,7 @@
+---
+
+test_win_get_url_link: http://docs.ansible.com
+test_win_get_url_path: "C:\\Users\\{{ansible_ssh_user}}\\docs_index.html"
+test_win_get_url_invalid_link: http://docs.ansible.com/skynet_module.html
+test_win_get_url_invalid_path: "Q:\\Filez\\Cyberdyne.html"
+test_win_get_url_dir_path: "C:\\Users\\{{ansible_ssh_user}}"
diff --git a/test/integration/roles/test_win_get_url/tasks/main.yml b/test/integration/roles/test_win_get_url/tasks/main.yml
index 26fb334c95..b0705eabd5 100644
--- a/test/integration/roles/test_win_get_url/tasks/main.yml
+++ b/test/integration/roles/test_win_get_url/tasks/main.yml
@@ -17,19 +17,81 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: remove test file if it exists
- raw: PowerShell -Command {Remove-Item "C:\Users\Administrator\win_get_url.jpg" -Force}
+ raw: >
+ PowerShell -Command Remove-Item "{{test_win_get_url_path}}" -Force
+ ignore_errors: true
- name: test win_get_url module
- win_get_url: url=http://placehold.it/10x10.jpg dest='C:\Users\Administrator\win_get_url.jpg'
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_path}}"
register: win_get_url_result
-- name: check win_get_url result
+- name: check that url was downloaded
assert:
that:
- "not win_get_url_result|failed"
- "win_get_url_result|changed"
+ - "win_get_url_result.win_get_url.url"
+ - "win_get_url_result.win_get_url.dest"
-# FIXME:
-# - Test invalid url
-# - Test invalid dest, when dest is directory
-# - Test idempotence when downloading same url/dest (not yet implemented)
+- name: test win_get_url module again (force should be yes by default)
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_path}}"
+ register: win_get_url_result_again
+
+- name: check that url was downloaded again
+ assert:
+ that:
+ - "not win_get_url_result_again|failed"
+ - "win_get_url_result_again|changed"
+
+- name: test win_get_url module again with force=no
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_path}}"
+ force: no
+ register: win_get_url_result_noforce
+
+- name: check that url was not downloaded again
+ assert:
+ that:
+ - "not win_get_url_result_noforce|failed"
+ - "not win_get_url_result_noforce|changed"
+
+- name: test win_get_url module with url that returns a 404
+ win_get_url:
+ url: "{{test_win_get_url_invalid_link}}"
+ dest: "{{test_win_get_url_path}}"
+ register: win_get_url_result_invalid_link
+ ignore_errors: true
+
+- name: check that the download failed for an invalid url
+ assert:
+ that:
+ - "win_get_url_result_invalid_link|failed"
+
+- name: test win_get_url module with an invalid path
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_invalid_path}}"
+ register: win_get_url_result_invalid_path
+ ignore_errors: true
+
+- name: check that the download failed for an invalid path
+ assert:
+ that:
+ - "win_get_url_result_invalid_path|failed"
+
+- name: test win_get_url module with a valid path that is a directory
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_dir_path}}"
+ register: win_get_url_result_dir_path
+ ignore_errors: true
+
+- name: check that the download failed if dest is a directory
+ assert:
+ that:
+ - "win_get_url_result_dir_path|failed"