summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_get_url
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2016-10-13 10:03:19 -0700
committerJohn R Barker <john@johnrbarker.com>2016-10-13 18:03:19 +0100
commitc2ec86cb78f3c43bc5f2484d1888571e27225702 (patch)
tree43602995d1b5b009de1e1d4a7bc1a835f60204b7 /test/integration/targets/win_get_url
parent9182619fef4151d04d28b30b8a6f33e469560f5f (diff)
downloadansible-c2ec86cb78f3c43bc5f2484d1888571e27225702.tar.gz
Migrate Windows CI roles to test targets. (#18005)
Diffstat (limited to 'test/integration/targets/win_get_url')
-rw-r--r--test/integration/targets/win_get_url/defaults/main.yml6
-rw-r--r--test/integration/targets/win_get_url/tasks/main.yml105
2 files changed, 111 insertions, 0 deletions
diff --git a/test/integration/targets/win_get_url/defaults/main.yml b/test/integration/targets/win_get_url/defaults/main.yml
new file mode 100644
index 0000000000..c7a90e599f
--- /dev/null
+++ b/test/integration/targets/win_get_url/defaults/main.yml
@@ -0,0 +1,6 @@
+---
+
+test_win_get_url_link: http://docs.ansible.com
+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_path: "{{ test_win_get_url_dir_path }}\\docs_index.html" \ No newline at end of file
diff --git a/test/integration/targets/win_get_url/tasks/main.yml b/test/integration/targets/win_get_url/tasks/main.yml
new file mode 100644
index 0000000000..52e49672d2
--- /dev/null
+++ b/test/integration/targets/win_get_url/tasks/main.yml
@@ -0,0 +1,105 @@
+# test code for the win_get_url module
+# (c) 2014, Chris Church <chris@ninemoreminutes.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- name: get tempdir path
+ raw: $env:TEMP
+ register: tempdir
+
+- name: set output path dynamically
+ set_fact:
+ test_win_get_url_dir_path: "{{ tempdir.stdout_lines[0] }}"
+
+- name: remove test file if it exists
+ raw: >
+ PowerShell -Command Remove-Item "{{test_win_get_url_path}}" -Force
+ ignore_errors: true
+
+- name: test win_get_url module
+ win_get_url:
+ url: "{{test_win_get_url_link}}"
+ dest: "{{test_win_get_url_path}}"
+ register: 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"
+
+- 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"