-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests to see if pre_model_hook works for tests around snowflake_warehouse #1070
Changes from 4 commits
c4f89cc
9d50d06
c45b801
b7c647e
b254a50
0185022
ae16ab7
305bf77
98974e2
9533012
52716e0
3f37148
e6b9ae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,35 +3,34 @@ | |
|
||
import os | ||
|
||
|
||
models__override_warehouse_sql = """ | ||
{{ config(snowflake_warehouse=env_var('SNOWFLAKE_TEST_ALT_WAREHOUSE', 'DBT_TEST_ALT'), materialized='table') }} | ||
select current_warehouse() as warehouse | ||
|
||
""" | ||
|
||
models__expected_warehouse_sql = """ | ||
{{ config(materialized='table') }} | ||
select '{{ env_var("SNOWFLAKE_TEST_ALT_WAREHOUSE", "DBT_TEST_ALT") }}' as warehouse | ||
|
||
""" | ||
|
||
models__invalid_warehouse_sql = """ | ||
{{ config(snowflake_warehouse='DBT_TEST_DOES_NOT_EXIST') }} | ||
select current_warehouse() as warehouse | ||
|
||
""" | ||
|
||
project_config_models__override_warehouse_sql = """ | ||
{{ config(materialized='table') }} | ||
select current_warehouse() as warehouse | ||
|
||
""" | ||
|
||
project_config_models__expected_warehouse_sql = """ | ||
{{ config(materialized='table') }} | ||
select '{{ env_var("SNOWFLAKE_TEST_ALT_WAREHOUSE", "DBT_TEST_ALT") }}' as warehouse | ||
""" | ||
|
||
project_config_models__invalid_warehouse_sql = """ | ||
{{ config(materialized='table') }} | ||
select current_warehouse() as warehouse | ||
""" | ||
|
||
|
||
|
@@ -90,3 +89,25 @@ def test_snowflake_override_ok(self, project): | |
] | ||
) | ||
check_relations_equal(project.adapter, ["OVERRIDE_WAREHOUSE", "EXPECTED_WAREHOUSE"]) | ||
|
||
|
||
class TestInvalidConfigWarehouse: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"invalid_warehouse.sql": project_config_models__invalid_warehouse_sql, | ||
} | ||
|
||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return { | ||
"config-version": 2, | ||
"models": { | ||
"test": { | ||
"snowflake_warehouse": "DBT_TEST_DOES_NOT_EXIST", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, nicely done - we should expect the dbt test to try using a Snowflake warehouse that doesn't exist ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. went ahead and also added a assert to catch if that error message stops showing up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the sake of completeness, can we add a positive test case that uses this config option, just to make sure it's setting it? The error message we're getting in the negative test case is pretty general. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a new test |
||
}, | ||
}, | ||
} | ||
|
||
def test_snowflake_override_invalid(self, project): | ||
run_dbt(["run", "--models", "invalid_warehouse"], expect_pass=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to put these logs behind condition of warehouses being different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@McKnight-42 I don't think we should add any new logging here. The actual queries being run (
select current_warehouse() as warehouse
+use warehouse different_warehouse
) are already appearing in the logs.