Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
nits
  • Loading branch information
ChenyuLInx committed Jun 30, 2023
commit c844191e48ac802c202974bb7fd2d1b47575e76f
15 changes: 6 additions & 9 deletions tests/functional/compile/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def test_compile_inline_not_add_node(self, project):
manifest = parse_result.result
assert len(manifest.nodes) == 4
dbt = dbtRunner(manifest=manifest)
dbt = dbtRunner()
dbt.invoke(
["compile", "--inline", "select * from {{ ref('second_model') }}"],
populate_cache=False,
Expand All @@ -200,19 +199,17 @@ def test_compile_inline_not_add_node(self, project):

def test_compile_inline_syntax_error(self, project, mocker):
patched_fire_event = mocker.patch("dbt.task.compile.fire_event")
dbt = dbtRunner()
res = dbt.invoke(["compile", "--inline", "select * from {{ ref(1) }}"])
# Event for parsing error
with pytest.raises(DbtException, match="Error parsing inline query"):
run_dbt(["compile", "--inline", "select * from {{ ref(1) }}"])
# Event for parsing error fired
patched_fire_event.assert_called_once()
Copy link
Contributor Author

@ChenyuLInx ChenyuLInx Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really find a better way to test things here other than making sure we call fire event and re-raised a proper error.
Also running with run_and_capture doesn't work because of the final exception being raise. I also think we should reduce the need to depending on testing the logs in the long term.

Happy to take suggestions here.

assert str(res.exception) == "Error parsing inline query"

def test_compile_inline_ref_node_not_exist(self, project, mocker):
patched_fire_event = mocker.patch("dbt.task.compile.fire_event")
dbt = dbtRunner()
res = dbt.invoke(["compile", "--inline", "select * from {{ ref('i') }}"])
# Event for parsing error
with pytest.raises(DbtException, match="Error parsing inline query"):
run_dbt(["compile", "--inline", "select * from {{ ref('third_model') }}"])
# Event for parsing error fired
patched_fire_event.assert_called_once()
assert str(res.exception) == "Error parsing inline query"

def test_graph_summary_output(self, project):
"""Ensure that the compile command generates a file named graph_summary.json
Expand Down