1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

added test for environment directive

This commit is contained in:
Brian Coca 2015-08-21 00:37:17 -04:00
parent 2787b3acac
commit 01708cc824
2 changed files with 56 additions and 1 deletions

View file

@ -21,7 +21,7 @@ VAULT_PASSWORD_FILE = vault-password
CONSUL_RUNNING := $(shell python consul_running.py)
all: parsing test_var_precedence unicode test_templating_settings non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths
all: parsing test_var_precedence unicode test_templating_settings environment non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths
parsing:
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario5
@ -38,6 +38,9 @@ unicode:
test_templating_settings:
ansible-playbook test_templating_settings.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
environment:
ansible-playbook test_environment.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) $(TEST_FLAGS)
non_destructive:
ansible-playbook non_destructive.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)

View file

@ -0,0 +1,52 @@
- hosts: testhost
vars:
- test1:
key1: val1
roles:
- { role: prepare_tests }
tasks:
- name: check that envvar does not exist
shell: echo $key1
register: test_env
- assert:
that:
- '"val1" not in test_env.stdout'
- name: check that envvar does exist
shell: echo $key1
environment: "{{test1}}"
register: test_env2
- assert:
that:
- '"val1" in test_env2.stdout'
- hosts: testhost
tasks:
vars:
- test1:
key1: val1
- test2:
key1: not1
other1: val2
environment: "{{test1}}"
tasks:
- name: check that play envvar does exist
shell: echo $key1
register: test_env
- assert:
that:
- '"val1" in test_env.stdout'
- name: check that task envvar does exist
shell: echo $key1; echo $other1
register: test_env2
environment: "{{test2}}"
- assert:
that:
- '"val1" not in test_env2.stdout'
- '"not1" in test_env2.stdout'
- '"val2" in test_env2.stdout'