mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
parent
512b2c7389
commit
1b9d437be8
16 changed files with 406 additions and 1 deletions
7
tests/integration/targets/git_config_info/aliases
Normal file
7
tests/integration/targets/git_config_info/aliases
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
azp/posix/3
|
||||
skip/aix
|
||||
destructive
|
11
tests/integration/targets/git_config_info/files/gitconfig
Normal file
11
tests/integration/targets/git_config_info/files/gitconfig
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
[credential "https://some.com"]
|
||||
username = yolo
|
||||
[user]
|
||||
name = foobar
|
||||
[push]
|
||||
pushoption = merge_request.create
|
||||
pushoption = merge_request.draft
|
7
tests/integration/targets/git_config_info/meta/main.yml
Normal file
7
tests/integration/targets/git_config_info/meta/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
dependencies:
|
||||
- setup_remote_tmp_dir
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- import_tasks: "setup_file.yml"
|
||||
|
||||
- name: getting all system configs
|
||||
git_config_info:
|
||||
scope: system
|
||||
register: get_result1
|
||||
|
||||
- name: getting all system configs for a key
|
||||
git_config_info:
|
||||
name: user.name
|
||||
scope: system
|
||||
register: get_result2
|
||||
|
||||
- name: assert value is correct
|
||||
assert:
|
||||
that:
|
||||
- get_result1.config_value == ""
|
||||
- 'get_result1.config_values == {}'
|
||||
- get_result2.config_value == ""
|
||||
- 'get_result2.config_values == {"user.name": []}'
|
||||
...
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- include_tasks: "{{ item.import_file }}"
|
||||
|
||||
- name: getting all values (as list) for a file config
|
||||
git_config_info:
|
||||
scope: "{{ item.git_scope }}"
|
||||
path: "{{ item.git_file | default(omit) }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert value is correct
|
||||
assert:
|
||||
that:
|
||||
- get_result.config_value == ""
|
||||
- 'get_result.config_values == {"credential.https://some.com.username": ["yolo"], "user.name": ["foobar"], "push.pushoption": ["merge_request.create", "merge_request.draft"]}'
|
||||
...
|
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- include_tasks: "{{ item.import_file }}"
|
||||
|
||||
- name: getting only a single value (as string) from an option with multiple values in the git config file
|
||||
git_config_info:
|
||||
name: push.pushoption
|
||||
scope: "{{ item.git_scope }}"
|
||||
path: "{{ item.git_file | default(omit) }}"
|
||||
register: get_result
|
||||
|
||||
- name: assert value is correct
|
||||
assert:
|
||||
that:
|
||||
- get_result.config_value == "merge_request.create"
|
||||
- 'get_result.config_values == {"push.pushoption": ["merge_request.create", "merge_request.draft"]}'
|
||||
...
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- include_tasks: "{{ item.import_file }}"
|
||||
|
||||
- name: getting simple file value1
|
||||
git_config_info:
|
||||
name: user.name
|
||||
scope: "{{ item.git_scope }}"
|
||||
path: "{{ item.git_file | default(omit) }}"
|
||||
register: get_result1
|
||||
|
||||
- name: getting simple file value2
|
||||
git_config_info:
|
||||
name: "credential.https://some.com.username"
|
||||
scope: "{{ item.git_scope }}"
|
||||
path: "{{ item.git_file | default(omit) }}"
|
||||
register: get_result2
|
||||
|
||||
- name: getting not existing value
|
||||
git_config_info:
|
||||
name: "user.email"
|
||||
scope: "{{ item.git_scope }}"
|
||||
path: "{{ item.git_file | default(omit) }}"
|
||||
register: get_result3
|
||||
|
||||
- name: assert value is correct
|
||||
assert:
|
||||
that:
|
||||
- get_result1.config_value == "foobar"
|
||||
- 'get_result1.config_values == {"user.name": ["foobar"]}'
|
||||
- get_result2.config_value == "yolo"
|
||||
- 'get_result2.config_values == {"credential.https://some.com.username": ["yolo"]}'
|
||||
- get_result3.config_value == ""
|
||||
- 'get_result3.config_values == {"user.email": []}'
|
||||
...
|
33
tests/integration/targets/git_config_info/tasks/main.yml
Normal file
33
tests/integration/targets/git_config_info/tasks/main.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# test code for the git_config_info module
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: setup
|
||||
import_tasks: setup.yml
|
||||
|
||||
- block:
|
||||
- include_tasks: get_simple_value.yml
|
||||
loop:
|
||||
- { import_file: setup_global.yml, git_scope: 'global' }
|
||||
- { import_file: setup_file.yml, git_scope: 'file', git_file: "{{ remote_tmp_dir }}/gitconfig_file" }
|
||||
|
||||
- include_tasks: get_multi_value.yml
|
||||
loop:
|
||||
- { import_file: setup_global.yml, git_scope: 'global' }
|
||||
- { import_file: setup_file.yml, git_scope: 'file', git_file: "{{ remote_tmp_dir }}/gitconfig_file" }
|
||||
|
||||
- include_tasks: get_all_values.yml
|
||||
loop:
|
||||
- { import_file: setup_global.yml, git_scope: 'global' }
|
||||
- { import_file: setup_file.yml, git_scope: 'file', git_file: "{{ remote_tmp_dir }}/gitconfig_file" }
|
||||
|
||||
- include_tasks: error_handling.yml
|
||||
when: git_installed is succeeded and git_version.stdout is version(git_version_supporting_includes, ">=")
|
||||
...
|
15
tests/integration/targets/git_config_info/tasks/setup.yml
Normal file
15
tests/integration/targets/git_config_info/tasks/setup.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: verify that git is installed so this test can continue
|
||||
command: which git
|
||||
register: git_installed
|
||||
ignore_errors: true
|
||||
|
||||
- name: get git version, only newer than {{git_version_supporting_includes}} has includes option
|
||||
shell: "git --version | grep 'git version' | sed 's/git version //'"
|
||||
register: git_version
|
||||
ignore_errors: true
|
||||
...
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# ------
|
||||
# set up : set gitconfig with value
|
||||
- name: delete global config
|
||||
file:
|
||||
path: ~/.gitconfig
|
||||
state: absent
|
||||
|
||||
- name: set up file config
|
||||
copy:
|
||||
src: gitconfig
|
||||
dest: "{{ remote_tmp_dir }}/gitconfig_file"
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# ------
|
||||
# set up : set gitconfig with value
|
||||
- name: delete file config
|
||||
file:
|
||||
path: "{{ remote_tmp_dir }}/gitconfig_file"
|
||||
state: absent
|
||||
|
||||
- name: setup global config
|
||||
copy:
|
||||
src: gitconfig
|
||||
dest: ~/.gitconfig
|
7
tests/integration/targets/git_config_info/vars/main.yml
Normal file
7
tests/integration/targets/git_config_info/vars/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
git_version_supporting_includes: 1.7.10
|
||||
...
|
Loading…
Add table
Add a link
Reference in a new issue