mirror of
https://github.com/dbt-labs/dbt-core
synced 2025-12-17 19:31:34 +00:00
Add test for unit testing model that depends on input model with alias (#12217)
This commit is contained in:
52
tests/functional/unit_testing/test_ut_aliases.py
Normal file
52
tests/functional/unit_testing/test_ut_aliases.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import pytest
|
||||
|
||||
from dbt.tests.util import run_dbt
|
||||
|
||||
model_with_alias_sql = """
|
||||
{{
|
||||
config(
|
||||
alias='beautiful_alias',
|
||||
schema='events',
|
||||
materialized='view'
|
||||
)
|
||||
}}
|
||||
|
||||
select
|
||||
'foo' as foo
|
||||
"""
|
||||
|
||||
model_tested = """
|
||||
select * from {{ ref('model_with_alias') }}
|
||||
"""
|
||||
|
||||
unit_test_yml = """
|
||||
unit_tests:
|
||||
- name: test_model_with_alias_input
|
||||
model: model_tested
|
||||
given:
|
||||
- input: ref('model_with_alias')
|
||||
rows:
|
||||
- {foo: bar }
|
||||
- {foo: foo }
|
||||
expect:
|
||||
rows:
|
||||
- {foo: bar }
|
||||
- {foo: foo }
|
||||
"""
|
||||
|
||||
|
||||
class TestUnitTestInputWithAlias:
|
||||
@pytest.fixture(scope="class")
|
||||
def models(self):
|
||||
return {
|
||||
"model_with_alias.sql": model_with_alias_sql,
|
||||
"model_tested.sql": model_tested,
|
||||
"unit_test.yml": unit_test_yml,
|
||||
}
|
||||
|
||||
def test_input_with_alias(self, project):
|
||||
results = run_dbt(["run"])
|
||||
assert len(results) == 2
|
||||
|
||||
results = run_dbt(["test"])
|
||||
assert len(results) == 1
|
||||
Reference in New Issue
Block a user