Skip to content

Commit

Permalink
Update functional tests to cover this case
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 committed Sep 17, 2024
1 parent c6b8f7e commit 4c78e81
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions tests/functional/unit_testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
FROM {{ ref('my_model_a') }}
"""

test_my_model_a_yml = """
models:
- name: my_model_a
columns:
- name: id
tests:
- not_null
"""

test_my_model_yml = """
unit_tests:
- name: test_my_model
Expand Down
14 changes: 13 additions & 1 deletion tests/functional/unit_testing/test_ut_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
my_model_a_sql,
my_model_b_sql,
my_model_vars_sql,
test_my_model_a_yml,
test_my_model_yml,
)

Expand All @@ -21,6 +22,7 @@ def models(self):
"my_model_a.sql": my_model_a_sql,
"my_model_b.sql": my_model_b_sql,
"test_my_model.yml": test_my_model_yml + datetime_test,
"test_my_model_a.yml": test_my_model_a_yml,
}

@pytest.fixture(scope="class")
Expand All @@ -32,13 +34,14 @@ def test_unit_test_list(self, project):
results = run_dbt(["run"])
assert len(results) == 3
results = run_dbt(["test"], expect_pass=False)
assert len(results) == 5
assert len(results) == 6

results = run_dbt(["list"])
expected = [
"test.my_model",
"test.my_model_a",
"test.my_model_b",
"test.not_null_my_model_a_id",
"unit_test:test.test_my_model",
"unit_test:test.test_my_model_datetime",
"unit_test:test.test_my_model_empty",
Expand Down Expand Up @@ -81,3 +84,12 @@ def test_unit_test_list(self, project):
for result in results:
json_result = json.loads(result)
assert json_result["model"] == "my_model"

results = run_dbt(["list", "--resource-type", "unit_test"])
assert len(results) == 5

results = run_dbt(["list", "--resource-type", "test"])
assert len(results) == 1

results = run_dbt(["list", "--resource-type", "unit_test", "test"])
assert len(results) == 6

0 comments on commit 4c78e81

Please sign in to comment.