ansible/test/integration/targets/win_pester/tasks/test.yml
Jordan Borean 762fcf78b9
win_pester - Align dir scanning with Pester's defaults (#64880)
* win_pester - Align dir scanning with Pester's defaults

Co-authored-by: Coby Caldwell <cobycaldwell@gmail.com>

* Fix sanity issues
2019-11-15 13:53:30 +10:00

134 lines
4.2 KiB
YAML

---
- name: Run Pester test(s) specifying a fake test file
win_pester:
path: '{{test_path}}\fakefile.ps1'
register: fake_file
failed_when: '"Cannot find file or directory: ''" + test_path + "\\fakefile.ps1'' as it does not exist" not in fake_file.msg'
- name: Run Pester test(s) specifying a fake folder
win_pester:
path: '{{test_path }}\fakedir'
register: fake_folder
failed_when: '"Cannot find file or directory: ''" + test_path + "\\fakedir'' as it does not exist" not in fake_folder.msg'
- name: Run Pester test(s) specifying a test file and a higher pester version
win_pester:
path: '{{test_path}}\test01.tests.ps1'
minimum_version: '6.0.0'
register: invalid_version
failed_when: '"Pester version is not greater or equal to 6.0.0" not in invalid_version.msg'
- name: Run Pester test(s) specifying a test file
win_pester:
path: '{{test_path}}\test01.tests.ps1'
register: file_result
- name: assert Run Pester test(s) specify a test file
assert:
that:
- file_result.changed
- not file_result.failed
- file_result.output.TotalCount == 1
- name: Run Pester test(s) specifying a test file and with a minimum mandatory Pester version
win_pester:
path: '{{test_path}}\test01.tests.ps1'
minimum_version: 3.0.0
register: file_result_with_version
- name: assert Run Pester test(s) specifying a test file and a minimum mandatory Pester version
assert:
that:
- file_result_with_version.changed
- not file_result_with_version.failed
- file_result_with_version.output.TotalCount == 1
- name: Run Pester test(s) located in a folder. Folder path end with '\'
win_pester:
path: '{{test_path}}\'
register: dir_with_ending_slash
- name: assert Run Pester test(s) located in a folder. Folder path end with '\'
assert:
that:
- dir_with_ending_slash.changed
- not dir_with_ending_slash.failed
- dir_with_ending_slash.output.TotalCount == 6
- name: Run Pester test(s) located in a folder. Folder path does not end with '\'
win_pester:
path: '{{test_path}}'
register: dir_without_ending_slash
- name: assert Run Pester test(s) located in a folder. Folder does not end with '\'
assert:
that:
- dir_without_ending_slash.changed
- not dir_without_ending_slash.failed
- dir_without_ending_slash.output.TotalCount == 6
- name: Run Pester test(s) located in a folder and with a minimum mandatory Pester version
win_pester:
path: '{{test_path}}'
minimum_version: 3.0.0
register: dir_with_version
- name: assert Run Pester test(s) located in a folder and with a minimum mandatory Pester version
assert:
that:
- dir_with_version.changed
- not dir_with_version.failed
- dir_with_version.output.TotalCount == 6
- name: Run Pester test(s) specifying a test file without specifying tag
win_pester:
path: '{{test_path}}\test03.tests.ps1'
register: test_no_tag
- name: assert Run Pester test(s) specifying a test file and all tests executed
assert:
that:
- test_no_tag.changed
- test_no_tag.output.TotalCount == 2
- name: Run Pester test(s) specifying a test file with tag
win_pester:
path: '{{test_path}}\test03.tests.ps1'
tags: tag1
register: test_with_tag
- name: Run Pester test(s) specifying a test file and only test with sepecified tag executed
assert:
that:
- test_with_tag.changed
- test_with_tag.output.TotalCount == 1
- name: Run Pester test(s) specifying a test file with parameters
win_pester:
path: '{{test_path}}\test04.tests.ps1'
test_parameters:
Process: lsass
Service: bits
register: test_with_parameter
- name: Run Pester test(s) specifying a test file with parameters
assert:
that:
- test_with_parameter.changed
- test_with_parameter.output.PassedCount == 2
- test_with_parameter.output.TotalCount == 2
- name: Run Pester test(s) specifying a test file by generating test result xml
win_pester:
path: '{{test_path}}\test03.tests.ps1'
output_file: '{{test_report_file}}'
- name: Checks if the output result file exists
win_stat:
path: '{{test_report_file}}'
register: test_output_file
- name: Checks if the output result file exists
assert:
that:
- test_output_file.stat.exists