Skip to content

Commit

Permalink
Fix failing model contract integration test (#378)
Browse files Browse the repository at this point in the history
* Fix failing model contract integration test

TestInvalidModelContractCheckConstraints tests that an invalid constraint causes a failure.  The test checked that the error message contained 'Constraint validation failed'.

dbt 1.5.2 changed the error message to 'Contract enforcement failed'.

Updated the test to check for either the original or updated message.

Signed-off-by: Raymond Cypher <raymond.cypher@databricks.com>
  • Loading branch information
rcypher-databricks authored Jun 27, 2023
1 parent 0338036 commit 0d2245b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/integration/model_contract/test_model_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ def test_invalid_check_constraints(self):
model_name = "invalid_check_constraint"
res = self.run_dbt(["run", "--select", model_name])
self.assertFalse(res.success, "dbt exit state did not match expected")
assert res.exception and "Constraint validation failed" in res.exception.msg

# dbt 1.5.2 changed the error message returned when an invalid constraint is
# encountered. Check for either to maintain compatability with all 1.5.x versions.
expectedErrors = ["Constraint validation failed", "Contract enforcement failed"]
assert res.exception and [m for m in expectedErrors if m in res.exception.msg]

@use_profile("databricks_cluster")
def test_databricks_cluster(self):
Expand Down

0 comments on commit 0d2245b

Please sign in to comment.