33
44from dbt .artifacts .schemas .results import RunStatus
55from dbt .exceptions import DbtProjectError
6- from dbt .tests .util import relation_from_name , run_dbt
6+ from dbt .tests .util import get_manifest , relation_from_name , run_dbt
77from dbt_common .exceptions import CompilationError
88
99# =============================================================================
@@ -70,6 +70,11 @@ def test_dbt_project_var_from_vars_file(self, project):
7070 assert len (results ) == 1
7171 assert results [0 ].status == RunStatus .Success
7272
73+ manifest = get_manifest (project .project_root )
74+ assert manifest is not None
75+ model = manifest .nodes ["model.test.model_with_var" ]
76+ assert model .config .meta ["project_var" ] == "project_var_from_file"
77+
7378
7479class TestDbtProjectVarCliOverridesFile :
7580 """dbt_project.yml with var should use CLI value when set in both vars.yml and cli"""
@@ -96,11 +101,17 @@ def test_cli_overrides_vars_file(self, project):
96101 cli_vars = {"my_var" : "from_cli" , "project_var" : "from_cli" }
97102 results = run_dbt (["run" , "--vars" , yaml .safe_dump (cli_vars )])
98103 assert len (results ) == 1
99- # Verify CLI value was used
104+
105+ # Verify CLI value was used in SQL model
100106 relation = relation_from_name (project .adapter , "model_with_var" )
101107 result = project .run_sql (f"select my_var_value from { relation } " , fetch = "one" )
102108 assert result [0 ] == "from_cli"
103109
110+ # Verify CLI value was used to render dbt_project.yml
111+ manifest = get_manifest (project .project_root )
112+ model = manifest .nodes ["model.test.model_with_var" ]
113+ assert model .config .meta ["project_var" ] == "from_cli"
114+
104115
105116class TestDbtProjectVarMissingFromVarsFile :
106117 """dbt should throw error if dbt_project.yml expects a var not present in vars.yml"""
0 commit comments