-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update functional tests to cover this case * Revert "Update functional tests to cover this case" This reverts commit 4c78e81. * New functional tests to cover the resource_type config * Separate data tests from unit tests for `resource_types` config of `dbt list` and `dbt build` * Changelog entry
- Loading branch information
Showing
6 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Fix `--resource-type test` for `dbt list` and `dbt build` | ||
time: 2024-09-17T17:44:46.121032-06:00 | ||
custom: | ||
Author: dbeatty10 | ||
Issue: "10730" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import pytest | ||
from fixtures import ( # noqa: F401 | ||
my_model_a_sql, | ||
my_model_b_sql, | ||
my_model_sql, | ||
test_my_model_a_yml, | ||
test_my_model_pass_yml, | ||
) | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
EXPECTED_MODELS = [ | ||
"test.my_model", | ||
"test.my_model_a", | ||
"test.my_model_b", | ||
] | ||
|
||
EXPECTED_DATA_TESTS = [ | ||
"test.not_null_my_model_a_a", | ||
"test.not_null_my_model_a_id", | ||
] | ||
|
||
EXPECTED_UNIT_TESTS = [ | ||
"unit_test:test.test_my_model", | ||
] | ||
|
||
|
||
class TestUnitTestResourceTypes: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"my_model.sql": my_model_sql, | ||
"my_model_a.sql": my_model_a_sql, | ||
"my_model_b.sql": my_model_b_sql, | ||
"test_my_model.yml": test_my_model_pass_yml, | ||
"test_my_model_a.yml": test_my_model_a_yml, | ||
} | ||
|
||
def test_unit_test_list(self, project): | ||
results = run_dbt(["run"]) | ||
|
||
# unit tests | ||
results = run_dbt(["list", "--resource-type", "unit_test"]) | ||
assert sorted(results) == EXPECTED_UNIT_TESTS | ||
|
||
results = run_dbt(["list", "--exclude-resource-types", "model", "test"]) | ||
assert sorted(results) == EXPECTED_UNIT_TESTS | ||
|
||
# data tests | ||
results = run_dbt(["list", "--resource-type", "test"]) | ||
assert sorted(results) == EXPECTED_DATA_TESTS | ||
|
||
results = run_dbt(["list", "--exclude-resource-types", "unit_test", "model"]) | ||
assert sorted(results) == EXPECTED_DATA_TESTS | ||
|
||
results = run_dbt(["build", "--resource-type", "test"]) | ||
assert len(results) == len(EXPECTED_DATA_TESTS) | ||
|
||
results = run_dbt(["build", "--exclude-resource-types", "unit_test", "model"]) | ||
assert len(results) == len(EXPECTED_DATA_TESTS) | ||
|
||
# models | ||
results = run_dbt(["list", "--resource-type", "model"]) | ||
assert len(results) == len(EXPECTED_MODELS) | ||
|
||
results = run_dbt(["list", "--exclude-resource-type", "unit_test", "test"]) | ||
assert sorted(results) == EXPECTED_MODELS | ||
|
||
results = run_dbt(["build", "--resource-type", "model"]) | ||
assert len(results) == len(EXPECTED_MODELS) | ||
|
||
results = run_dbt(["build", "--exclude-resource-type", "unit_test", "test"]) | ||
assert len(results) == len(EXPECTED_MODELS) |