Skip to content

Commit

Permalink
Add tests for checking DBT_ENV_SECRET_s don't break logging
Browse files Browse the repository at this point in the history
[CT-1783](#6568) describes
a bug in dbt-core 1.0-1.3 wherein when a `DBT_ENV_SECRET_` all
`{{ log("logging stuff", info=True) }}` invocations break. This commit
adds a test for this for two reasons:
1. Ensure we don't regress to this behavior going forward
2. Act as a base commit for making the backport fixes to dbt-core 1.0-1.3
  • Loading branch information
QMalcolm committed Apr 12, 2023
1 parent 29ed63b commit a0208f7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/unit/test_base_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from dbt.context.base import BaseContext
from jinja2.runtime import Undefined

Expand All @@ -10,3 +12,11 @@ def test_log_jinja_undefined(self):
BaseContext.log(msg=Undefined(), info=True)
except Exception as e:
assert False, f"Logging an jinja2.Undefined object raises an exception: {e}"

def test_log_with_dbt_env_secret(self):
# regression test for CT-1783
try:
os.environ["DBT_ENV_SECRET_LOG_TEST"] = "cats_are_cool"
BaseContext.log({"fact1": "I like cats"}, info=True)
except Exception as e:
assert False, f"Logging while a `DBT_ENV_SECRET` was set raised an exception: {e}"

0 comments on commit a0208f7

Please sign in to comment.