Skip to content

Commit

Permalink
fix(tests): use regex to avoid focal whitespace in jinja debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
blackboxsw committed May 27, 2024
1 parent 19cb8cf commit 120b534
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions tests/unittests/test_builtin_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import copy
import errno
import os
import re
from textwrap import dedent

import pytest
Expand Down Expand Up @@ -356,19 +357,6 @@ def test_render_jinja_payload_logs_jinja_vars_on_debug(self, caplog):
"## template: jinja\n#!/bin/sh\necho hi from {{ v1.hostname }}"
)
instance_data = {"v1": {"hostname": "foo"}, "instance-id": "iid"}
expected_log = dedent(
"""\
Converted jinja variables
{
"hostname": "foo",
"instance-id": "iid",
"instance_id": "iid",
"v1": {
"hostname": "foo"
}
}
"""
)
assert (
render_jinja_payload(
payload=payload,
Expand All @@ -378,7 +366,12 @@ def test_render_jinja_payload_logs_jinja_vars_on_debug(self, caplog):
)
== "#!/bin/sh\necho hi from foo"
)
assert expected_log in caplog.text
expected_log = (
'.*Converted jinja variables\\n.*{\\n.*"hostname": "foo",\\n.*'
'"instance-id": "iid",\\n.*"instance_id": "iid",\\n.*'
'"v1": {\\n.*"hostname": "foo"\\n.*}'
)
assert re.match(expected_log, caplog.text, re.DOTALL)

@skipUnlessJinja()
def test_render_jinja_payload_replaces_missing_variables_and_warns(
Expand Down

0 comments on commit 120b534

Please sign in to comment.