Skip to content

Commit

Permalink
template: Add integration tests for `trim_blocks'
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Tsitsimpis <alextsi@arrikto.com>
  • Loading branch information
alextsits committed Mar 23, 2018
1 parent 261f909 commit 073235a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Hello world

Goodbye
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello world
Goodbye
36 changes: 36 additions & 0 deletions test/integration/targets/template/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,42 @@
- 'import_as_with_context_diff_result.stdout == ""'
- "import_as_with_context_diff_result.rc == 0"

# VERIFY trim_blocks

- name: Render a template with "trim_blocks" set to False
template:
src: trim_blocks.j2
dest: "{{output_dir}}/trim_blocks_false.templated"
trim_blocks: False
register: trim_blocks_false_result

- name: Get checksum of known good trim_blocks_false.expected
stat:
path: "{{role_path}}/files/trim_blocks_false.expected"
register: trim_blocks_false_good

- name: Verify templated trim_blocks_false matches known good using checksum
assert:
that:
- "trim_blocks_false_result.checksum == trim_blocks_false_good.stat.checksum"

- name: Render a template with "trim_blocks" set to True
template:
src: trim_blocks.j2
dest: "{{output_dir}}/trim_blocks_true.templated"
trim_blocks: True
register: trim_blocks_true_result

- name: Get checksum of known good trim_blocks_true.expected
stat:
path: "{{role_path}}/files/trim_blocks_true.expected"
register: trim_blocks_true_good

- name: Verify templated trim_blocks_true matches known good using checksum
assert:
that:
- "trim_blocks_true_result.checksum == trim_blocks_true_good.stat.checksum"

# VERIFY lstrip_blocks

- name: Check support for lstrip_blocks in Jinja2
Expand Down
4 changes: 4 additions & 0 deletions test/integration/targets/template/templates/trim_blocks.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% if True %}
Hello world
{% endif %}
Goodbye

0 comments on commit 073235a

Please sign in to comment.