From 43236ca0ed0710d8b2a8539e9bebd3a27506cef1 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Thu, 19 Jun 2014 13:32:43 -0500 Subject: [PATCH] Add basic tests for win_get_url and win_msi modules. --- examples/scripts/upgrade_to_ps3.ps1 | 2 +- .../roles/test_win_get_url/tasks/main.yml | 35 ++++++++++++++++ .../roles/test_win_msi/tasks/main.yml | 41 +++++++++++++++++++ test/integration/test_winrm.yml | 2 + 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 test/integration/roles/test_win_get_url/tasks/main.yml create mode 100644 test/integration/roles/test_win_msi/tasks/main.yml diff --git a/examples/scripts/upgrade_to_ps3.ps1 b/examples/scripts/upgrade_to_ps3.ps1 index 1e1c1e3305..d7909e1596 100644 --- a/examples/scripts/upgrade_to_ps3.ps1 +++ b/examples/scripts/upgrade_to_ps3.ps1 @@ -79,4 +79,4 @@ else $FileName = $DownLoadUrl.Split('/')[-1] download-file $downloadurl "$powershellpath\$filename" -Start-Process -FilePath $powershellpath\$filename -WindowStyle Hidden -Wait +Start-Process -FilePath $powershellpath\$filename -WindowStyle Hidden diff --git a/test/integration/roles/test_win_get_url/tasks/main.yml b/test/integration/roles/test_win_get_url/tasks/main.yml new file mode 100644 index 0000000000..26fb334c95 --- /dev/null +++ b/test/integration/roles/test_win_get_url/tasks/main.yml @@ -0,0 +1,35 @@ +# test code for the win_get_url module +# (c) 2014, Chris Church + +# 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 . + +- name: remove test file if it exists + raw: PowerShell -Command {Remove-Item "C:\Users\Administrator\win_get_url.jpg" -Force} + +- name: test win_get_url module + win_get_url: url=http://placehold.it/10x10.jpg dest='C:\Users\Administrator\win_get_url.jpg' + register: win_get_url_result + +- name: check win_get_url result + assert: + that: + - "not win_get_url_result|failed" + - "win_get_url_result|changed" + +# FIXME: +# - Test invalid url +# - Test invalid dest, when dest is directory +# - Test idempotence when downloading same url/dest (not yet implemented) diff --git a/test/integration/roles/test_win_msi/tasks/main.yml b/test/integration/roles/test_win_msi/tasks/main.yml new file mode 100644 index 0000000000..d0d7034d78 --- /dev/null +++ b/test/integration/roles/test_win_msi/tasks/main.yml @@ -0,0 +1,41 @@ +# test code for the win_msi module +# (c) 2014, Chris Church + +# 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 . + +- name: use win_get_url module to download msi + win_get_url: url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi dest='C:\7z922-x64.msi' + register: win_get_url_result + +- name: install 7zip msi + win_msi: path="{{ win_get_url_result.win_get_url.dest }}" + register: win_msi_install_result + +- name: check win_msi install result + assert: + that: + - "not win_msi_install_result|failed" + - "win_msi_install_result|changed" + +- name: uninstall 7zip msi + win_msi: path="{{ win_get_url_result.win_get_url.dest }}" state=absent + register: win_msi_uninstall_result + +- name: check win_msi uninstall result + assert: + that: + - "not win_msi_uninstall_result|failed" + - "win_msi_uninstall_result|changed" diff --git a/test/integration/test_winrm.yml b/test/integration/test_winrm.yml index 81443d4dbf..f8e205f0e2 100644 --- a/test/integration/test_winrm.yml +++ b/test/integration/test_winrm.yml @@ -10,3 +10,5 @@ - { role: test_win_slurp, tags: test_win_slurp } - { role: test_win_fetch, tags: test_win_fetch } - { role: test_win_stat, tags: test_win_stat } + - { role: test_win_get_url, tags: test_win_get_url } + - { role: test_win_msi, tags: test_win_msi }