diff options
author | Brian Scholer <1260690+briantist@users.noreply.github.com> | 2020-02-27 01:05:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 16:05:37 +1000 |
commit | 9afe87139a0916a42335d56c55ed3f3523e4168e (patch) | |
tree | 4eee6935e61afb60ef9af6cec7df28bbd26f8365 /test/integration | |
parent | 10feb24870bee04d845c21367d695385f01885db (diff) | |
download | ansible-9afe87139a0916a42335d56c55ed3f3523e4168e.tar.gz |
Add win_psrepository_info module (#67594)
* Add win_psrepository_info module
* Change return type
* Add tests for win_psrepository_info
Diffstat (limited to 'test/integration')
8 files changed, 167 insertions, 0 deletions
diff --git a/test/integration/targets/win_psrepository_info/aliases b/test/integration/targets/win_psrepository_info/aliases new file mode 100644 index 0000000000..423ce39108 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/aliases @@ -0,0 +1 @@ +shippable/windows/group2 diff --git a/test/integration/targets/win_psrepository_info/defaults/main.yml b/test/integration/targets/win_psrepository_info/defaults/main.yml new file mode 100644 index 0000000000..e027079875 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/defaults/main.yml @@ -0,0 +1,10 @@ +--- +run_check_mode: False +suffix: "{{ '(check mode)' if run_check_mode else '' }}" +default_repository_name: PSGallery + +second_repository_name: PowerShellGetDemo +second_repository_source_location: https://www.myget.org/F/powershellgetdemo/api/v2 + +third_repository_name: OtherRepo +third_repository_source_location: http://httpbin.org/get diff --git a/test/integration/targets/win_psrepository_info/meta/main.yml b/test/integration/targets/win_psrepository_info/meta/main.yml new file mode 100644 index 0000000000..504d9eb770 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_win_psget diff --git a/test/integration/targets/win_psrepository_info/tasks/contains_all_fields.yml b/test/integration/targets/win_psrepository_info/tasks/contains_all_fields.yml new file mode 100644 index 0000000000..6f3e6f5009 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/tasks/contains_all_fields.yml @@ -0,0 +1,21 @@ +# This file is part of Ansible + +# Copyright: (c) 2020, Brian Scholer <@briantist> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Check for key ('{{ key }}') in result + assert: + that: key in dict_to_check + loop_control: + loop_var: key + loop: + - name + - installation_policy + - package_management_provider + - provider_options + - publish_location + - source_location + - script_source_location + - script_publish_location + - registered + - trusted diff --git a/test/integration/targets/win_psrepository_info/tasks/empty.yml b/test/integration/targets/win_psrepository_info/tasks/empty.yml new file mode 100644 index 0000000000..9bc6d4c644 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/tasks/empty.yml @@ -0,0 +1,19 @@ +# This file is part of Ansible + +# Copyright: (c) 2020, Brian Scholer <@briantist> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Tests against the empty set of repositories + block: + - name: Get repository info {{ suffix }} + win_psrepository_info: + register: repo_info + + - name: Assert that the correct structure is returned {{ suffix }} + assert: + that: + - repo_info.repositories is defined + - repo_info.repositories is sequence() + - repo_info.repositories | length == 0 + # block + check_mode: "{{ run_check_mode }}" diff --git a/test/integration/targets/win_psrepository_info/tasks/main.yml b/test/integration/targets/win_psrepository_info/tasks/main.yml new file mode 100644 index 0000000000..8e92dc6321 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/tasks/main.yml @@ -0,0 +1,51 @@ +# This file is part of Ansible + +# Copyright: (c) 2020, Brian Scholer <@briantist> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Unregister all repositories + win_shell: | + Get-PSRepository | Unregister-PSRepository + +- block: + - name: Run Empty Tests + import_tasks: empty.yml + + - name: Run Empty Tests (check mode) + import_tasks: empty.yml + vars: + run_check_mode: True + + - name: Add the default repository + win_shell: | + Register-PSRepository -Default + + - name: Single Repository Tests + import_tasks: single.yml + + - name: Single Repository Tests (check mode) + import_tasks: single.yml + vars: + run_check_mode: True + + - name: Add two more repositories + win_shell: | + Register-PSRepository -Name '{{ second_repository_name }}' -SourceLocation '{{ second_repository_source_location }}' + Register-PSRepository -Name '{{ third_repository_name }}' -SourceLocation '{{ third_repository_source_location }}' + + - name: Multi Repository Tests + import_tasks: multiple.yml + + - name: Multi Repository Tests (check mode) + import_tasks: multiple.yml + vars: + run_check_mode: True + + always: + - name: Unregister all repositories + win_shell: | + Get-PSRepository | Unregister-PSRepository + + - name: Ensure only the default repository remains + win_shell: | + Register-PSRepository -Default diff --git a/test/integration/targets/win_psrepository_info/tasks/multiple.yml b/test/integration/targets/win_psrepository_info/tasks/multiple.yml new file mode 100644 index 0000000000..8c5b986e7a --- /dev/null +++ b/test/integration/targets/win_psrepository_info/tasks/multiple.yml @@ -0,0 +1,37 @@ +# This file is part of Ansible + +# Copyright: (c) 2020, Brian Scholer <@briantist> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Tests against mutiple repositories + block: + - name: Get all repository info {{ suffix }} + win_psrepository_info: + register: repo_info + + - name: Assert that the correct structure is returned {{ suffix }} + assert: + that: + - repo_info.repositories is defined + - repo_info.repositories is sequence() + - repo_info.repositories | length == 3 + + - include_tasks: contains_all_fields.yml + vars: + dict_to_check: "{{ item }}" + loop: "{{ repo_info.repositories }}" + + - name: Get two repositories with a filter {{ suffix }} + win_psrepository_info: + name: P* + register: repo_info + + - name: Assert that the correct two repositories were returned {{ suffix }} + assert: + that: + - repo_info.repositories | length == 2 + - default_repository_name in (repo_info.repositories | map(attribute='name') | list) + - second_repository_name in (repo_info.repositories | map(attribute='name') | list) + + # block + check_mode: "{{ run_check_mode }}" diff --git a/test/integration/targets/win_psrepository_info/tasks/single.yml b/test/integration/targets/win_psrepository_info/tasks/single.yml new file mode 100644 index 0000000000..00071ec556 --- /dev/null +++ b/test/integration/targets/win_psrepository_info/tasks/single.yml @@ -0,0 +1,26 @@ +# This file is part of Ansible + +# Copyright: (c) 2020, Brian Scholer <@briantist> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- name: Tests against a single repository ({{ default_repository_name }}) + block: + - name: Get repository info {{ suffix }} + win_psrepository_info: + name: "{{ default_repository_name }}" + register: repo_info + + - name: Assert that the correct structure is returned {{ suffix }} + assert: + that: + - repo_info.repositories is defined + - repo_info.repositories is sequence() + - repo_info.repositories | length == 1 + - repo_info.repositories[0].name == default_repository_name + + - include_tasks: contains_all_fields.yml + vars: + dict_to_check: "{{ repo_info.repositories[0] }}" + + # block + check_mode: "{{ run_check_mode }}" |