Skip to content

Commit

Permalink
Add failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Dec 9, 2024
1 parent 457c361 commit 091c3bb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/functional/relation_tests/dynamic_table_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
"""


AUTO_DYNAMIC_TABLE = """
{{ config(
materialized='dynamic_table',
snowflake_warehouse='DBT_TESTING',
target_lag='2 minutes',
refresh_mode='AUTO',
) }}
select * from {{ ref('my_seed') }}
"""


DYNAMIC_TABLE_DOWNSTREAM = """
{{ config(
materialized='dynamic_table',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from dbt.tests.util import run_dbt
from dbt.tests.util import assert_message_in_logs, run_dbt, run_dbt_and_capture

from tests.functional.relation_tests.dynamic_table_tests import models
from tests.functional.utils import query_relation_type
Expand Down Expand Up @@ -46,3 +46,33 @@ class TestBasicIcebergOn(TestBasic):
@pytest.fixture(scope="class")
def project_config_update(self):
return {"flags": {"enable_iceberg_materializations": True}}


class TestAutoConfigDoesntRebuild:
DT_NAME = "my_dynamic_table"

@pytest.fixture(scope="class", autouse=True)
def seeds(self):
return {"my_seed.csv": models.SEED}

@pytest.fixture(scope="class", autouse=True)
def models(self):
yield {
f"{self.DT_NAME}.sql": models.AUTO_DYNAMIC_TABLE,
}

def test_auto_config_doesnt_rebuild(self, project):
model_qualified_name = f"{project.database}.{project.test_schema}.{self.DT_NAME}"

run_dbt(["seed"])
_, logs = run_dbt_and_capture(["--debug", "run", "--select", f"{self.DT_NAME}.sql"])
assert_message_in_logs(f"create dynamic table {model_qualified_name}", logs)
assert_message_in_logs("refresh_mode = AUTO", logs)

_, logs = run_dbt_and_capture(["--debug", "run", "--select", f"{self.DT_NAME}.sql"])
assert_message_in_logs(f"create dynamic table {model_qualified_name}", logs, False)
assert_message_in_logs("refresh_mode = AUTO", logs, False)
assert_message_in_logs(
f"No configuration changes were identified on on: `{model_qualified_name}`. Continuing.",
logs,
)

0 comments on commit 091c3bb

Please sign in to comment.