Skip to content

Commit

Permalink
Add test that should fail
Browse files Browse the repository at this point in the history
  • Loading branch information
sivel committed Jun 8, 2023
1 parent 6fcbed0 commit b4baa20
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 29 deletions.
4 changes: 4 additions & 0 deletions test/integration/targets/template/arg_template_overrides.j2
@@ -0,0 +1,4 @@
var_a: << var_a >>
var_b: << var_b >>
var_c: << var_c >>
var_d: << var_d >>
28 changes: 0 additions & 28 deletions test/integration/targets/template/in_template_overrides.yml

This file was deleted.

2 changes: 1 addition & 1 deletion test/integration/targets/template/runme.sh
Expand Up @@ -39,7 +39,7 @@ ansible-playbook 72262.yml -v "$@"
ansible-playbook unsafe.yml -v "$@"

# ensure Jinja2 overrides from a template are used
ansible-playbook in_template_overrides.yml -v "$@"
ansible-playbook template_overrides.yml -v "$@"

ansible-playbook lazy_eval.yml -i ../../inventory -v "$@"

Expand Down
38 changes: 38 additions & 0 deletions test/integration/targets/template/template_overrides.yml
@@ -0,0 +1,38 @@
- hosts: localhost
gather_facts: false
vars:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
var_a: "value"
var_b: "{{ var_a }}"
var_c: "<< var_a >>"
tasks:
- set_fact:
var_d: "{{ var_a }}"

- template:
src: in_template_overrides.j2
dest: '{{ output_dir }}/in_template_overrides.out'

- template:
src: arg_template_overrides.j2
dest: '{{ output_dir }}/arg_template_overrides.out'
variable_start_string: '<<'
variable_end_string: '>>'

- command: cat '{{ output_dir }}/in_template_overrides.out'
register: in_template_overrides_out

- command: cat '{{ output_dir }}/arg_template_overrides.out'
register: arg_template_overrides_out

- assert:
that:
- "'var_a: value' in in_template_overrides_out.stdout"
- "'var_b: value' in in_template_overrides_out.stdout"
- "'var_c: << var_a >>' in in_template_overrides_out.stdout"
- "'var_d: value' in in_template_overrides_out.stdout"

- "'var_a: value' in arg_template_overrides_out.stdout"
- "'var_b: value' in arg_template_overrides_out.stdout"
- "'var_c: << var_a >>' in arg_template_overrides_out.stdout"
- "'var_d: value' in arg_template_overrides_out.stdout"

0 comments on commit b4baa20

Please sign in to comment.