Compare commits

...

9 Commits

Author SHA1 Message Date
Kshitij Aranke
521c485cb2 comment out ctx mixedcase change for windows 2024-07-17 16:05:28 +01:00
Kshitij Aranke
25cd208209 comment out ctx lowercase change for windows 2024-07-17 14:36:38 +01:00
Kshitij Aranke
d5b33768d3 Merge branch 'main' into fix_10422 2024-07-16 22:22:01 +01:00
Kshitij Aranke
0aa48444a1 Merge branch 'main' into fix_10422 2024-07-15 21:54:27 +01:00
Kshitij Aranke
1af2cd77d5 Discard changes to .gitignore 2024-07-15 20:12:14 +01:00
Kshitij Aranke
bfd6aa8f11 Discard changes to core/dbt/context/base.py 2024-07-15 20:12:07 +01:00
Kshitij Aranke
a6cbc83b66 Merge branch 'main' into fix_10422 2024-07-15 15:14:33 +01:00
Kshitij Aranke
37dc363251 Add conditional to do case-insensitive env var matching on Windows 2024-07-12 18:26:35 +01:00
Kshitij Aranke
7367e5e0b2 fix #10422: add test for env_var casing on windows 2024-07-12 17:52:40 +01:00

View File

@@ -0,0 +1,64 @@
import os
import pytest
from dbt.tests.util import run_dbt
context_sql = """
{{
config(
materialized='table'
)
}}
select
'{{ env_var("local_user", "") }}' as lowercase,
'{{ env_var("LOCAL_USER", "") }}' as uppercase,
'{{ env_var("lOcAl_UsEr", "") }}' as mixedcase
"""
class TestEnvVars:
@pytest.fixture(scope="class")
def models(self):
return {"context.sql": context_sql}
@pytest.fixture(scope="class", autouse=True)
def setup(self):
os.environ["local_user"] = "dan"
yield
del os.environ["local_user"]
def get_ctx_vars(self, project):
fields = [
"lowercase",
"uppercase",
"mixedcase",
]
field_list = ", ".join(['"{}"'.format(f) for f in fields])
query = "select {field_list} from {schema}.context".format(
field_list=field_list, schema=project.test_schema
)
vals = project.run_sql(query, fetch="all")
ctx = dict([(k, v) for (k, v) in zip(fields, vals[0])])
return ctx
def test_env_vars(
self,
project,
):
results = run_dbt(["run"])
assert len(results) == 1
ctx = self.get_ctx_vars(project)
# assert ctx["lowercase"] == "dan"
# Windows env-vars are not case-sensitive, but Linux/macOS ones are
# So on Windows, the uppercase and mixedcase vars should also resolve to "dan"
if os.name == "nt":
assert ctx["uppercase"] == "dan"
# assert ctx["mixedcase"] == "dan"
else:
assert ctx["uppercase"] == ""
assert ctx["mixedcase"] == ""