Skip to content

Commit

Permalink
convert 027 cycle test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Oct 18, 2022
1 parent 73aebd8 commit 5b82a2c
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 60 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions test/integration/027_cycle_tests/complex_cycle_models/readme

This file was deleted.

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions test/integration/027_cycle_tests/test_cycles.py

This file was deleted.

71 changes: 71 additions & 0 deletions tests/functional/cycles/test_cycles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import pytest

from dbt.tests.util import run_dbt

model_a_sql = """
select * from {{ ref('model_b') }}
"""

model_b_sql = """
select * from {{ ref('model_a') }}
"""

complex_cycle__model_a_sql = """
select 1 as id
"""

complex_cycle__model_b_sql = """
select * from {{ ref('model_a') }}s
union all
select * from {{ ref('model_e') }}
"""

complex_cycle__model_c_sql = """
select * from {{ ref('model_b') }}
"""

complex_cycle__model_d_sql = """
select * from {{ ref('model_c') }}
"""

complex_cycle__model_e_sql = """
select * from {{ ref('model_e') }}
"""


class TestSimpleCycle:
@pytest.fixture(scope="class")
def models(self):
return {
"model_a.sql": model_a_sql,
"model_b.sql": model_b_sql
}

def test_postgres_simple_cycle(self, project):
with pytest.raises(RuntimeError) as exc:
run_dbt(["run"], expect_pass=False)
expected_msg = "Found a cycle"
assert expected_msg in str(exc.value)


class TestComplexCycle:
@pytest.fixture(scope="class")
def models(self):
# The cycle in this graph looks like:
# A -> B -> C -> D
# ^ |
# | |
# +--- E <--+
return {
"model_a.sql": complex_cycle__model_a_sql,
"model_b.sql": complex_cycle__model_b_sql,
"model_c.sql": complex_cycle__model_c_sql,
"model_d.sql": complex_cycle__model_d_sql,
"model_e.sql": complex_cycle__model_e_sql,
}

def test_postgres_complex_cycle(self, project):
with pytest.raises(RuntimeError) as exc:
run_dbt(["run"], expect_pass=False)
expected_msg = "Found a cycle"
assert expected_msg in str(exc.value)

0 comments on commit 5b82a2c

Please sign in to comment.