Skip to content

Commit

Permalink
Update log introspection in functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 committed Apr 11, 2023
1 parent e025f5c commit be78a7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion core/dbt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ def get_mismatches(self) -> agate.Table:
sql_col["name"],
sql_col["data_type"],
yaml_col["data_type"],
"data type",
"data type mismatch",
]
mismatches += [dict(zip(column_names, row))]
break
Expand Down
31 changes: 9 additions & 22 deletions tests/adapter/dbt/tests/adapter/constraints/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,8 @@ def test__constraints_wrong_column_names(self, project, string_type, int_type):

assert contract_actual_config.enforced is True

expected_compile_error = "Please ensure the name, data_type, and number of columns in your `yml` file match the columns in your SQL file."
expected_schema_file_columns = (
f"Schema File Columns: id {int_type}, color {string_type}, date_day {string_type}"
)
expected_sql_file_columns = (
f"SQL File Columns: color {string_type}, error {int_type}, date_day {string_type}"
)

assert expected_compile_error in log_output
assert expected_schema_file_columns in log_output
assert expected_sql_file_columns in log_output
expected = ["id", "error", "missing in definition", "missing in contract"]
assert all([exp in log_output for exp in expected])

def test__constraints_wrong_column_data_types(
self, project, string_type, int_type, schema_int_type, data_types
Expand Down Expand Up @@ -129,17 +120,13 @@ def test__constraints_wrong_column_data_types(

assert contract_actual_config.enforced is True

expected_compile_error = "Please ensure the name, data_type, and number of columns in your `yml` file match the columns in your SQL file."
expected_sql_file_columns = (
f"SQL File Columns: wrong_data_type_column_name {error_data_type}"
)
expected_schema_file_columns = (
f"Schema File Columns: wrong_data_type_column_name {wrong_schema_error_data_type}"
)

assert expected_compile_error in log_output
assert expected_schema_file_columns in log_output
assert expected_sql_file_columns in log_output
expected = [
"wrong_data_type_column_name",
error_data_type,
wrong_schema_error_data_type,
"data type mismatch",
]
assert all([exp in log_output for exp in expected])

def test__constraints_correct_column_data_types(self, project, data_types):
for (sql_column_value, schema_data_type, _) in data_types:
Expand Down

0 comments on commit be78a7d

Please sign in to comment.