mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Add winrm integration tests for raw, script and ping modules.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
@ECHO OFF
|
||||
ECHO We can even run a batch file!
|
||||
@@ -0,0 +1,2 @@
|
||||
# Test script to make sure the Ansible script module works.
|
||||
Write-Host "Woohoo! We can run a PowerShell script via Ansible!"
|
||||
@@ -0,0 +1,7 @@
|
||||
# Test script to make sure the Ansible script module works when arguments are
|
||||
# passed to the script.
|
||||
|
||||
foreach ($i in $args)
|
||||
{
|
||||
Write-Host $i;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# http://stackoverflow.com/questions/9948517/how-to-stop-a-powershell-script-on-the-first-error
|
||||
#$ErrorActionPreference = "Stop";
|
||||
# http://stackoverflow.com/questions/15777492/why-are-my-powershell-exit-codes-always-0
|
||||
|
||||
trap
|
||||
{
|
||||
Write-Error -ErrorRecord $_
|
||||
exit 1;
|
||||
}
|
||||
|
||||
throw "Oh noes I has an error"
|
||||
59
test/integration/roles/test_win_script/tasks/main.yml
Normal file
59
test/integration/roles/test_win_script/tasks/main.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
|
||||
- name: run simple test script
|
||||
script: test_script.ps1
|
||||
register: test_script_result
|
||||
|
||||
- name: check that script ran
|
||||
assert:
|
||||
that:
|
||||
- "test_script_result.rc == 0"
|
||||
- "test_script_result.stdout"
|
||||
- "'Woohoo' in test_script_result.stdout"
|
||||
- "not test_script_result.stderr"
|
||||
- "not test_script_result|failed"
|
||||
- "test_script_result|changed"
|
||||
|
||||
- name: run test script that takes arguments
|
||||
script: test_script_with_args.ps1 /this /that /other
|
||||
register: test_script_with_args_result
|
||||
|
||||
- name: check that script ran and received arguments
|
||||
assert:
|
||||
that:
|
||||
- "test_script_with_args_result.rc == 0"
|
||||
- "test_script_with_args_result.stdout"
|
||||
- "test_script_with_args_result.stdout_lines[0] == '/this'"
|
||||
- "test_script_with_args_result.stdout_lines[1] == '/that'"
|
||||
- "test_script_with_args_result.stdout_lines[2] == '/other'"
|
||||
- "not test_script_with_args_result.stderr"
|
||||
- "not test_script_with_args_result|failed"
|
||||
- "test_script_with_args_result|changed"
|
||||
|
||||
- name: run test script that has errors
|
||||
script: test_script_with_errors.ps1
|
||||
register: test_script_with_errors_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: check that script ran but failed with errors
|
||||
assert:
|
||||
that:
|
||||
- "test_script_with_errors_result.rc != 0"
|
||||
- "not test_script_with_errors_result.stdout"
|
||||
- "test_script_with_errors_result.stderr"
|
||||
- "test_script_with_errors_result|failed"
|
||||
- "test_script_with_errors_result|changed"
|
||||
|
||||
- name: run simple batch file
|
||||
script: test_script.bat
|
||||
register: test_batch_result
|
||||
|
||||
- name: check that batch file ran
|
||||
assert:
|
||||
that:
|
||||
- "test_batch_result.rc == 0"
|
||||
- "test_batch_result.stdout"
|
||||
- "'batch' in test_batch_result.stdout"
|
||||
- "not test_batch_result.stderr"
|
||||
- "not test_batch_result|failed"
|
||||
- "test_batch_result|changed"
|
||||
Reference in New Issue
Block a user