Compare commits

...

1 Commits

Author SHA1 Message Date
Jeremy Cohen
622c589f4f Extend contract removed breaking change detection to state:modified 2024-11-18 23:17:53 +01:00
2 changed files with 19 additions and 0 deletions

View File

@@ -690,6 +690,7 @@ class StateSelectorMethod(SelectorMethod):
different_contents = not new.same_contents(old, adapter_type) # type: ignore
upstream_macro_change = self.check_macros_modified(new)
check_modified_contract = new.check_modified_contract(old)
return different_contents or upstream_macro_change
def check_unmodified_content(

View File

@@ -676,6 +676,16 @@ class TestDeleteUnversionedContractedModel(BaseModifiedState):
assert expected_warning in logs
assert expected_change in logs
# the same but for general-purpose state:modified
_, logs = run_dbt_and_capture(
["run", "--models", "state:modified", "--state", "./state"]
)
expected_warning = "While comparing to previous project state, dbt detected a breaking change to an unversioned model"
expected_change = "Contracted model 'model.test.table_model' was deleted or renamed"
assert expected_warning in logs
assert expected_change in logs
class TestDeleteVersionedContractedModel(BaseModifiedState):
MODEL_UNIQUE_ID = "model.test.table_model.v1"
@@ -697,6 +707,14 @@ class TestDeleteVersionedContractedModel(BaseModifiedState):
e.value
)
# the same but for general-purpose state:modified
with pytest.raises(ContractBreakingChangeError) as e:
run_dbt(["run", "--models", "state:modified", "--state", "./state"])
assert "Contracted model 'model.test.table_model.v1' was deleted or renamed." in str(
e.value
)
class TestDisableUnversionedContractedModel(BaseModifiedState):
MODEL_UNIQUE_ID = "model.test.table_model"